-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path17B.py
39 lines (35 loc) · 937 Bytes
/
17B.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
A = int(input()[12:])
B = int(input()[12:])
C = int(input()[12:])
input()
arr = [int(i) for i in input()[9:].split(",")]
n = len(arr)
def run(a):
combo = lambda x: x if x < 4 else {4: a, 5: b, 6: c}[x]
i = b = c = 0
out = []
while i < n - 1:
code, op = arr[i], arr[i + 1]
i += 2
match code:
case 0:
a //= pow(2, combo(op))
case 1:
b ^= op
case 2:
b = combo(op) % 8
case 3:
i = op if a != 0 else i
case 4:
b ^= c
case 5:
out.append(combo(op) % 8)
case 6:
b = a // pow(2, combo(op))
case 7:
c = a // pow(2, combo(op))
return out
ans = [0]
for i in range(len(arr)):
ans = [n * 8 + a for n in ans for a in range(8) if arr[-i - 1 :] == run(n * 8 + a)]
print(ans[0])