Paste: AoC 2024 Day 3
Author: | erg |
Mode: | factor |
Date: | Tue, 3 Dec 2024 15:12:08 |
Plain Text |
USE: pcre2
"mul\\([0-9]+,[0-9]+\\)"
findall
[ first second "mul(" ?head drop ")" ?tail drop "," splitting:split [ string>number ] map product ] map-sum
USE: pcre2
"do\\(\\)|don't\\(\\)|mul\\([0-9]+,[0-9]+\\)"
findall
[ first second ] map
[ [ { [ "do(" head? ] [ "don't(" head? ] } 1|| ] [ "mul(" head? ] bi* or ] monotonic-split
[ first "don't()" = ] reject
concat
[ "do()" = ] reject
[ "mul(" ?head drop ")" ?tail drop "," splitting:split [ string>number ] map product ] map-sum
New Annotation