aoc2024/d03/run.awk

8 lines
215 B
Awk
Raw Permalink Normal View History

2024-12-03 08:57:20 +00:00
# run with
2025-01-04 18:24:56 +00:00
# grep -oP 'mul\([0-9]+[,][0-9]+\)|do\(\)|don.t\(\)' input | tr '(,)' '\t\t\t' | awk -f this.awk
BEGIN {run=1}
$1=="mul" {P1+=$2*$3; P2+=run*$2*$3}
$1=="don't" {run=0}
$1=="do" {run=1}
END {print P1, P2}