Created
December 15, 2020 11:08
-
-
Save Danyc0/c42b1505a955f85fbcb5cf99521bd69f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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