Last active
December 3, 2018 09:27
-
-
Save JamesGardiner/e876bf68a22221a52df3e4492f85b0e0 to your computer and use it in GitHub Desktop.
AoC Day 1
This file contains hidden or 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("./day1_input.txt") as fp: | |
inputs = [int(line.strip("\n")) for line in fp.readlines()] | |
print(f"Answer: {sum(inputs)}") |
This file contains hidden or 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
from itertools import cycle | |
seen = set() | |
x = 0 | |
with open("./day1_input.txt") as fp: | |
inputs = [int(line.strip("\n")) for line in fp.readlines()] | |
for input in cycle(inputs): | |
x += input | |
if x in seen: | |
print(f"Seen twice: {x}") | |
break | |
seen.add(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment