-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBinary Game.py
66 lines (44 loc) · 1.29 KB
/
Binary Game.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
import pickle
from Basen import *
def passesxor(a, b, c):
a = a.get(2)
b = b.get(2)
c = c.get(2)
longest = 0
for number in [a, b, c]:
longest = max(longest, len(number))
a = "0" * (longest - len(a)) + a
b = "0" * (longest - len(b)) + b
c = "0" * (longest - len(c)) + c
result = ""
for digit in range(longest):
count = 0
for num in [a, b, c]:
if num[digit] == "1":
count += 1
if count % 2 == 0:
result += "0"
else:
result += "1"
if result == "0" * longest:
return True
return False
#print(passesxor(Number(10), Number(5), Number(15)))
if __name__ == '__main__':
v1 = Number(2)
v2 = Number(3)
v3 = Number(8)
passingsetsofNumbers = []
l = [v1, v2, v3]
while True:
if passesxor(*l):
passingsetsofNumbers.append(l.copy())
i = input(f"Here's the board:\n{l[0].get(2)}, {l[1].get(2)}, {l[2].get(2)}\nChoose a number to change (0, 1, 2): ")
if i.lower() == "":
break
else:
i = int(i)
change = int(input(f"Change {l[i].get(2)} to: "))
l[i] = Number(change)
with open("binaryout.pickle", "wb") as file:
pickle.dump(passingsetsofNumbers, file)