I have also updated get.py to download the problems as
`d<day>.txt` instead of `i<day>.txt`. That allows me
to get the day input via `__input__.replace('.py', '.txt')`
which is a little more concise. I don't know why
I didn't do this earlier.
29 lines
456 B
Python
29 lines
456 B
Python
def part_1(data):
|
|
r = 0
|
|
for x in data.splitlines():
|
|
r += int(x)
|
|
print(r)
|
|
|
|
|
|
def part_2(data):
|
|
seen = set()
|
|
r = 0
|
|
while True:
|
|
for x in data.splitlines():
|
|
r += int(x)
|
|
if r in seen:
|
|
print(r)
|
|
return
|
|
seen.add(r)
|
|
|
|
|
|
def main():
|
|
with open("i1.txt") as f:
|
|
data = f.read()
|
|
part_1(data)
|
|
part_2(data)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|