Files
2026-10-01 22:11:11 -04:00

36 lines
883 B
Python

def day1(data: str, part: int) -> int:
"""
day1 - Solve parts 1 and 2 for day Day1
:param data: input data as a string
:param part: part 1 or 2 of the puzzle
:return: int
"""
floor: int = 0 # track the floor we are on
in_basement: bool = False # have we made first entry into the basement?
char_position: int = 0 # track character number we enter the basement
for char in data:
if char == "(":
floor += 1
elif char == ")":
floor -= 1
if not in_basement:
char_position += 1
if floor < 0 and in_basement == False:
in_basement = True
if part == 1:
return floor
elif part == 2:
return char_position
else:
return -1
def day2(data: list, part: int) -> int:
pass
function_map = {
"1": day1,
}