Last active
December 3, 2018 14:53
-
-
Save synio-wesley/eee9878003cc643e06bbbfa67698c33e to your computer and use it in GitHub Desktop.
AOC 2018 - Day 1 - Python
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
# 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