Skip to content

Instantly share code, notes, and snippets.

@synio-wesley
Last active December 3, 2018 14:53
Show Gist options
  • Save synio-wesley/eee9878003cc643e06bbbfa67698c33e to your computer and use it in GitHub Desktop.
Save synio-wesley/eee9878003cc643e06bbbfa67698c33e to your computer and use it in GitHub Desktop.
AOC 2018 - Day 1 - Python
# Part 1
print(sum([int(num) for num in open('day1.txt')]))
# Part 2
diffs = [int(num) for num in open('day1.txt')]
freq = 0
freqs = {}
i = 0
while True:
freq += diffs[i % len(diffs)]
i += 1
if freq not in freqs:
freqs[freq] = 1
else:
print(freq)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment