rename stuff
This commit is contained in:
1 parent
7c3d439f6e
commit
97ddc36b62
325 files changed
+85
No files matched your search
@@ -0,0 +1,19 @@
|
||||
def next(num, turn, memo):
|
||||
if num not in memo:
|
||||
memo[num] = (0, turn)
|
||||
return 0
|
||||
memo[num] = (memo[num][1], turn)
|
||||
return memo[num][1] - memo[num][0]
|
||||
|
||||
|
||||
def solve(input, target):
|
||||
memo, n = {}, input[-1]
|
||||
for i, j in enumerate(input):
|
||||
memo[j] = (0, i)
|
||||
for t in range(len(input)-1, target-1):
|
||||
n = next(n, t, memo)
|
||||
return n
|
||||
|
||||
|
||||
print(solve([16, 12, 1, 0, 15, 7, 11], 2020))
|
||||
print(solve([16, 12, 1, 0, 15, 7, 11], 30000000))
|
||||
Reference in new issue
Block a user