From 7be7d0654b36cd00fc787af7fffbf8fc62895fd9 Mon Sep 17 00:00:00 2001 From: Starnakin Date: Tue, 3 Dec 2024 10:15:53 +0100 Subject: [PATCH] fix: 2024/day03 regex expression --- 2024/day03/part1.py | 2 +- 2024/day03/part2.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/2024/day03/part1.py b/2024/day03/part1.py index a6a184f..fd2eb2f 100644 --- a/2024/day03/part1.py +++ b/2024/day03/part1.py @@ -7,7 +7,7 @@ with open("input.txt") as f: total: int = 0 -for x, y in re.findall("mul\(([0-9]{0,3})\,([0-9]{0,3})\)", text): +for x, y in re.findall("mul\(([0-9]{1,3})\,([0-9]{1,3})\)", text): x, y = int(x), int(y) total += x * y diff --git a/2024/day03/part2.py b/2024/day03/part2.py index c3cbf63..15bc6ea 100644 --- a/2024/day03/part2.py +++ b/2024/day03/part2.py @@ -9,7 +9,7 @@ total: int = 0 do_or_not: bool = True -for x, y, don_t, do in re.findall("mul\(([0-9]{0,3})\,([0-9]{0,3})\)|(don\'t)|(do)", text): +for x, y, don_t, do in re.findall("mul\(([0-9]{1,3})\,([0-9]{1,3})\)|(don\'t\(\))|(do\(\))", text): if (do != ""): do_or_not = True elif (don_t != ""):