mirror of
https://github.com/thib8956/advent-of-code.git
synced 2025-08-24 08:21:57 +00:00
chore: create new project structure and aoc.py runner script
This commit is contained in:
19
adventofcode/2015/day1/day1.py
Normal file
19
adventofcode/2015/day1/day1.py
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
def main(inp):
|
||||
floor = 0
|
||||
basement = -1
|
||||
for i, c in enumerate(inp):
|
||||
if c == "(": floor += 1
|
||||
elif c == ")": floor -= 1
|
||||
if basement == -1 and floor == -1:
|
||||
basement = i + 1
|
||||
print("Part 1: ", floor)
|
||||
print("Part 2: ", basement)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
infile = sys.argv[1] if len(sys.argv) > 1 else "example.txt"
|
||||
with open(infile) as inp:
|
||||
main(inp.read().rstrip())
|
||||
|
Reference in New Issue
Block a user