don't accept numbers > 999 for the multiplication command

This commit is contained in:
Heiko Ludwig 2024-12-03 20:48:17 +01:00
parent c9141da37a
commit d858da19be

View file

@ -12,7 +12,7 @@ def get_lines(filename: str) -> list:
def part1_get_result_sum(lines: list) -> int: def part1_get_result_sum(lines: list) -> int:
result_sum = 0 result_sum = 0
pattern = re.compile(r"mul\((\d+),(\d+)\)") pattern = re.compile(r"mul\((\d{1,3}),(\d{1,3})\)")
for line in lines: for line in lines:
matches = re.findall(pattern, line) matches = re.findall(pattern, line)
for match in matches: for match in matches: