You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
382 B
22 lines
382 B
#!/usr/bin/env python3
|
|
|
|
from sys import argv
|
|
|
|
i = [int(x) for x in open(argv[1]).read().strip().split(",")]
|
|
|
|
a = {x:t+1 for t,x in enumerate(i[:-1])}
|
|
t = len(i)
|
|
l = i[-1]
|
|
def f(x):
|
|
global l,t
|
|
while t < x:
|
|
if l in a:
|
|
n = t - a[l]
|
|
else:
|
|
n = 0
|
|
a[l] = t
|
|
t += 1
|
|
l = n
|
|
return l
|
|
print(f(2020))
|
|
print(f(30000000))
|
|
|