From c1b917059bed554311cc3487c45ea5b98df23888 Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 4 Dec 2024 22:15:25 +0800 Subject: [PATCH] Update regex --- 2024/day-3/solution-2.sh | 2 +- 2024/day-4/solution-2.sh | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/2024/day-3/solution-2.sh b/2024/day-3/solution-2.sh index dcbe439..05a9c57 100644 --- a/2024/day-3/solution-2.sh +++ b/2024/day-3/solution-2.sh @@ -3,7 +3,7 @@ # Filter out do(), don't(), and mul() # then strip out tails to get do and don # strip out mul() to get numbers -grep -Po 'do\(\)|don(.)?t\(\)|mul\([0-9]+,[0-9]+\)' input | +grep -Po 'do\(\)|don.t\(\)|mul\([0-9]+,[0-9]+\)' input | grep -Po 'don|do|mul\([0-9]+,[0-9]+\)' | sed -E 's/^mul\(([0-9]+),([0-9]+)\)/\1 \2/g' | awk ' diff --git a/2024/day-4/solution-2.sh b/2024/day-4/solution-2.sh index 3ce5b40..626441d 100644 --- a/2024/day-4/solution-2.sh +++ b/2024/day-4/solution-2.sh @@ -4,7 +4,6 @@ paste -s -d '' input.txt | perl -lne ' print "$1$4$2$3" while - /(?<=(.).)(?<=(.).{138})A(?=.{138}(.))(?=.(.))/g + /(?<=(.).(.).{138})A(?=.{138}(.).(.))/g ' | - grep -Eo '(SM|MS){2}' | - wc -l + grep -Ec '(SM|MS){2}'