• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 19th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. f = open("code.txt", "r")
2.
3. l = []
5.     l.append(x.strip())
6.
7. def translate(letter):
8.     val = 0
9.     for i in range(5):
10.         val += int(letter[i])*(2**(4-i))
11.     print chr(val + 96),
12.
13. def ruru(code):
14.     r1 = [1, 1, 0, 0, 1, 1, 0, 0 ,0]
15.     r2 = [1, 1, 1, 0, 0, 0, 1, 0, 0]
16.     r3 = [1, 0, 1, 1, 0, 0, 0, 1, 0]
17.     r4 = [1, 0, 0, 1, 1, 0 ,0, 0, 1]
18.
19.     s1 = 0
20.     s2 = 0
21.     s3 = 0
22.     s4 = 0
23.     for i in range(9):
24.         digit = int(code[i])
25.         s1 += digit*r1[i]
26.         s2 += digit*r2[i]
27.         s3 += digit*r3[i]
28.         s4 += digit*r4[i]
29.     res = [s1%2, s2%2, s3%2, s4%2]
30.     return res
31.
32. # 1 1111
33. # 2 1100
34. # 3 0110
35. # 4 0011
36. # 5 1001
37. # 6 1000
38. # 7 0100
39. # 8 0010
40. # 9 0001
41. def correct(code):
42.     val = ruru(code)
43.     listed = list(code)
44.     if val == [1, 1, 1, 1]:
45.         listed[0] = str((int(listed[0]) + 1)%2)
46.         return "".join(listed)
47.     if val == [1, 1, 0, 0]:
48.         listed[1] = str((int(listed[1]) + 1)%2)
49.         return "".join(listed)
50.     if val == [0, 1, 1, 0]:
51.         listed[2] = str((int(listed[2]) + 1)%2)
52.         return "".join(listed)
53.     if val == [0, 0, 1, 1]:
54.         listed[3] = str((int(listed[3]) + 1)%2)
55.         return "".join(listed)
56.     if val == [1, 0, 0, 1]:
57.         listed[4] = str((int(listed[4]) + 1)%2)
58.         return "".join(listed)
59.     if val == [1, 0, 0, 0]:
60.         listed[5] = str((int(listed[5]) + 1)%2)
61.         return "".join(listed)
62.     if val == [0, 1, 0, 0]:
63.         listed[6] = str((int(listed[6]) + 1)%2)
64.         return "".join(listed)
65.     if val == [0, 0, 1, 0]:
66.         listed[7] = str((int(listed[7]) + 1)%2)
67.         return "".join(listed)
68.     if val == [0, 0, 0, 1]:
69.         listed[8] = str((int(listed[8]) + 1)%2)
70.         return "".join(listed)
71.     return code
72.
73. corrected = [correct(x) for x in l]
74. final = [x[0:5] for x in corrected]
75.
76. for x in final:
77.     translate(x)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?