33 lines
487 B
Python
33 lines
487 B
Python
#!/usr/bin/env python3
|
|
|
|
from typing import TextIO
|
|
|
|
|
|
f = open("day01.txt", "r")
|
|
floors = f.read().strip()
|
|
|
|
|
|
def part1() -> int:
|
|
return 0 + floors.count("(") - floors.count(")")
|
|
|
|
|
|
def part2() -> int:
|
|
position = 1
|
|
current = 0
|
|
|
|
for a in floors:
|
|
if a == "(":
|
|
current += 1
|
|
else:
|
|
current -= 1
|
|
|
|
if current == -1:
|
|
return position
|
|
|
|
position += 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(part1())
|
|
print(part2())
|