diff --git a/day_03/program.py b/day_03/program.py index e990273..bd5f517 100755 --- a/day_03/program.py +++ b/day_03/program.py @@ -12,8 +12,9 @@ def get_lines(filename: str) -> list: def part1_get_result_sum(lines: list) -> int: result_sum = 0 + pattern = re.compile(r"mul\((\d+),(\d+)\)") for line in lines: - matches = re.findall(r"mul\((\d+),(\d+)\)", line) + matches = re.findall(pattern, line) for match in matches: result_sum += int(match[0]) * int(match[1]) return result_sum