Skip to content

Instantly share code, notes, and snippets.

@JamesGardiner
Last active December 3, 2018 09:27
Show Gist options
  • Save JamesGardiner/e876bf68a22221a52df3e4492f85b0e0 to your computer and use it in GitHub Desktop.
Save JamesGardiner/e876bf68a22221a52df3e4492f85b0e0 to your computer and use it in GitHub Desktop.
AoC Day 1
with open("./day1_input.txt") as fp:
inputs = [int(line.strip("\n")) for line in fp.readlines()]
print(f"Answer: {sum(inputs)}")
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