advent-of-code/py/aoc/y2015/d01.py
2022-12-06 20:21:28 +01:00

11 lines
254 B
Python

def solve(inputstr):
steps = [1 if c == "(" else -1 for c in inputstr.strip()]
print(f"Part 1: {sum(steps)}")
at = 0
for i, step in enumerate(steps):
at += step
if at < 0:
break
print(f"Part 2: {i + 1}")