Skip to content

Instantly share code, notes, and snippets.

@Danyc0
Created December 15, 2020 11:08
Show Gist options
  • Save Danyc0/c42b1505a955f85fbcb5cf99521bd69f to your computer and use it in GitHub Desktop.
Save Danyc0/c42b1505a955f85fbcb5cf99521bd69f to your computer and use it in GitHub Desktop.
with open("input.txt") as f:
data = [int(i) for i in f.read().strip().split(',')]
print(data)
last_num = 0
history = {}
for i, num in enumerate(data):
if i != 0:
history[last_num] = i
last_num = num
for i in range(len(data), 30000000):
if last_num not in history:
history[last_num] = i
last_num = 0
else:
val = i - history[last_num]
history[last_num] = i
last_num = val
print(last_num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment