mirror of
https://github.com/thib8956/advent-of-code.git
synced 2026-11-06 10:02:27 +00:00
chore: create new project structure and aoc.py runner script
This commit is contained in:
1 parent
f76375d835
commit
e2964c6c36
91 files changed
+177
-113
No files matched your search
@@ -0,0 +1,24 @@
|
||||
#!/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__':
|
||||
import sys
|
||||
infile = sys.argv[1] if len(sys.argv) > 1 else "example.txt"
|
||||
with open(infile) as inp:
|
||||
main(inp.readlines())
|
||||
|
||||
Reference in new issue
Block a user