mirror of
https://github.com/thib8956/advent-of-code.git
synced 2025-07-01 14:25:48 +00:00
import more stuff
This commit is contained in:
22
2018/day1/day1.py
Normal file
22
2018/day1/day1.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
import itertools
|
||||
|
||||
|
||||
def main(inp):
|
||||
# Part 1
|
||||
changes = [int(n) for n in inp]
|
||||
print(sum(changes))
|
||||
freq = 0
|
||||
seen = {0}
|
||||
for num in itertools.cycle(changes):
|
||||
freq += num
|
||||
if freq in seen:
|
||||
print(freq)
|
||||
break
|
||||
seen.add(freq)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
with open("input.txt") as inp:
|
||||
main(inp.readlines())
|
||||
|
1025
2018/day1/input.txt
Normal file
1025
2018/day1/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user