aoc/2015/day01.py

33 lines
487 B
Python
Raw Normal View History

2023-05-07 19:01:38 -04:00
#!/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())