mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-26 21:30:31 +01:00
Add python implementation of day1, after the fact.
This commit is contained in:
1
day1-input.txt
Normal file
1
day1-input.txt
Normal file
File diff suppressed because one or more lines are too long
17
day1.py
Normal file
17
day1.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import fileinput
|
||||||
|
|
||||||
|
floor = 0
|
||||||
|
seenBasement = False
|
||||||
|
|
||||||
|
for line in fileinput.input():
|
||||||
|
for idx, c in enumerate(line.strip()):
|
||||||
|
if c == '(':
|
||||||
|
floor += 1
|
||||||
|
else:
|
||||||
|
floor -= 1
|
||||||
|
|
||||||
|
if not seenBasement and floor == -1:
|
||||||
|
seenBasement = True
|
||||||
|
print "Basement reached at", idx + 1
|
||||||
|
|
||||||
|
print "Finally arrived at", floor
|
||||||
Reference in New Issue
Block a user