-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path19.py
117 lines (90 loc) · 3.9 KB
/
19.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def test(i,j):
l = [109,424,203,1,21101,11,0,0,1106,0,282,21102,18,1,0,1105,1,259,1201,1,0,221,203,1,21101,0,31,0,1105,1,282,21102,1,38,0,1106,0,259,21001,23,0,2,22101,0,1,3,21102,1,1,1,21101,57,0,0,1106,0,303,1202,1,1,222,21002,221,1,3,20102,1,221,2,21101,259,0,1,21102,1,80,0,1105,1,225,21101,83,0,2,21101,91,0,0,1105,1,303,2102,1,1,223,20102,1,222,4,21102,259,1,3,21101,225,0,2,21101,225,0,1,21102,1,118,0,1105,1,225,20102,1,222,3,21101,0,51,2,21102,1,133,0,1105,1,303,21202,1,-1,1,22001,223,1,1,21102,1,148,0,1106,0,259,1201,1,0,223,21002,221,1,4,21002,222,1,3,21101,13,0,2,1001,132,-2,224,1002,224,2,224,1001,224,3,224,1002,132,-1,132,1,224,132,224,21001,224,1,1,21102,195,1,0,106,0,108,20207,1,223,2,21002,23,1,1,21102,-1,1,3,21101,0,214,0,1106,0,303,22101,1,1,1,204,1,99,0,0,0,0,109,5,2102,1,-4,249,21202,-3,1,1,21202,-2,1,2,22102,1,-1,3,21101,0,250,0,1105,1,225,22102,1,1,-4,109,-5,2106,0,0,109,3,22107,0,-2,-1,21202,-1,2,-1,21201,-1,-1,-1,22202,-1,-2,-2,109,-3,2106,0,0,109,3,21207,-2,0,-1,1206,-1,294,104,0,99,22101,0,-2,-2,109,-3,2105,1,0,109,5,22207,-3,-4,-1,1206,-1,346,22201,-4,-3,-4,21202,-3,-1,-1,22201,-4,-1,2,21202,2,-1,-1,22201,-4,-1,1,22101,0,-2,3,21101,0,343,0,1106,0,303,1105,1,415,22207,-2,-3,-1,1206,-1,387,22201,-3,-2,-3,21202,-2,-1,-1,22201,-3,-1,3,21202,3,-1,-1,22201,-3,-1,2,21202,-4,1,1,21102,384,1,0,1106,0,303,1105,1,415,21202,-4,-1,-4,22201,-4,-3,-4,22202,-3,-2,-2,22202,-2,-4,-4,22202,-3,-2,-3,21202,-4,-1,-2,22201,-3,-2,1,22101,0,1,-4,109,-5,2105,1,0]
inp = [j, i]
out = []
curr = 0
base = 0
l += [0] * 100000
while True:
code = l[curr] % 100
mode1 = l[curr] // 100 % 10
mode2 = l[curr] // 1000 % 10
mode3 = l[curr] // 10000 % 10
baseInp1 = l[curr + 1]
inp2 = l[curr + 2]
inp3 = l[curr + 3]
if mode1 == 0:
inp1 = l[baseInp1]
elif mode1 == 1:
inp1 = baseInp1
elif mode1 == 2:
baseInp1 += base
inp1 = l[baseInp1]
if mode2 == 0:
inp2 = l[inp2]
elif mode2 == 2:
inp2 = l[inp2 + base]
if mode3 == 2:
inp3 += base
if code == 1:
l[inp3] = inp1 + inp2
curr += 4
elif code == 2:
l[inp3] = inp1 * inp2
curr += 4
elif code == 3:
l[baseInp1] = inp.pop()
curr += 2
elif code == 4:
out.append(inp1)
curr += 2
elif code == 5:
if inp1 != 0:
curr = inp2
else:
curr += 3
elif code == 6:
if inp1 == 0:
curr = inp2
else:
curr += 3
elif code == 7:
if inp1 < inp2:
outV = 1
else:
outV = 0
l[inp3] = outV
curr += 4
elif code == 8:
if inp1 == inp2:
outV = 1
else:
outV = 0
l[inp3] = outV
curr += 4
elif code == 9:
base += inp1
curr += 2
elif code == 99:
break
else:
print('Bad')
break
return out[0]
start = 700
first = [0] * start
first_no = [0] * start
for i in range(start,10000):
testV = first[-1]
while not test(i, testV):
testV += 1
first.append(testV)
testV = max(testV,first_no[-1])
while test(i, testV):
testV += 1
first_no.append(testV)
if i > 100:
print(first_no[i], first_no[i - 99], first[i], first[i - 99])
print(i, min(first_no[i], first_no[i - 99]) - max(first[i], first[i - 99]))
if min(first_no[i], first_no[i - 99]) - max(first[i], first[i - 99]) >= 100:
break