-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecoder.py
71 lines (59 loc) · 1.57 KB
/
decoder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
print("Binary Decoder for Y_Univ Version 1.2 (by kimiroo)\n\nBinary code to alphabet converter for my univ homework\n~~designed to simplify(?) the decoding process~~")
# Initialize
isList = "f"
done = "f"
out = ""
lett = ""
outLett = ""
lst = ""
loopNo = -1
lstLen = 0
lstTipPnt = 0
while done == "f":
buffer = 0
lett = ""
loopNo = loopNo + 1
print("")
print("Loop: ",str(loopNo))
if isList == "f":
inp = input("Enter: ")
# Check if it is list
if inp[0] == "l":
print("List detected!")
isList = "t"
inp = inp.replace("l", "")
print("Converted:",inp)
#lst = list(inp)
#print(lst)
lst = list(inp.split(","))
#print(lst)
lstLen = len(lst)
lstTipPnt = lstLen - 1
print("OriLST: ",lst)
print("len: ", str(len(lst)))
if isList == "t":
inp = str(lst[loopNo])
if inp == "e":
done = "t"
inp = str(11110)
elif loopNo == lstTipPnt:
done = "t"
var = "0b" + inp
buffer = int(var, 2)
if int(buffer) >= 1:
if int(buffer) <= 26:
lett = chr(ord('`')+buffer)
print("Buffer: " + str(buffer),"/",lett)
else:
lett = "."
print("Buffer: " + str(buffer),"/",lett)
else:
lett = " "
print("Buffer: " + str(buffer),"/",lett)
out = out + str(buffer)
outLett = outLett + str(lett)
print("Output: " + out,"/",outLett)
# Break loop when 30
if lett == ".":
print("BREAK!")
break