mirror of
https://github.com/thib8956/advent-of-code.git
synced 2025-08-23 16:01:59 +00:00
20 lines
479 B
Python
20 lines
479 B
Python
#!/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())
|
|
|