-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path17.py
31 lines (28 loc) · 810 Bytes
/
17.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
import re
a, b, c, *nums = map(int, re.findall(r"\d+", open(0).read()))
def compute(A=a, B=b, C=c, pointer=0):
out = []
while pointer < len(nums):
num = nums[pointer+1]
combo = {4:A, 5:B, 6:C}.get(num, num)
match nums[pointer]:
case 0: A = A // 2**combo
case 1: B ^= num
case 2: B = combo % 8
case 3 if A != 0: pointer = num - 2
case 4: B ^= C
case 5: out.append(combo % 8)
case 6: B = A // 2**combo
case 7: C = A // 2**combo
pointer += 2
return out
print(*compute(), sep=",")
def find_A(A, at=15):
if at == -1:
print(A)
exit(0)
while True:
if nums[at:] == compute(A)[at:]:
find_A(A, at-1)
A += 8**at
find_A(8**15)