Reorganize

This commit is contained in:
Joscha 2018-12-03 08:50:27 +00:00
parent 009cfb0af3
commit 16eb74908a
7 changed files with 0 additions and 0 deletions

33
2018/01/solve.py Normal file
View file

@ -0,0 +1,33 @@
import sys
def load_freqs(filename):
freqs = []
with open(filename, "r") as f:
for line in f:
n = int(line[:-1])
freqs.append(n)
return freqs
# PART 2
def find_repeat(freqs):
total = 0
found = {total}
while True:
for n in freqs:
total += n
if total in found:
return total
else:
found.add(total)
def main(filename):
freqs = load_freqs(filename)
print(f"Solutions for {filename}")
print(f"Part 1: {sum(freqs)}")
print(f"Part 2: {find_repeat(freqs)}")
if __name__ == "__main__":
for filename in sys.argv[1:]:
main(filename)