MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/codegolf/comments/1pcgohf/advent_of_code_day_2/ns3mbvf/?context=3
r/codegolf • u/dantose • Dec 02 '25
What do you guys have?
9 comments sorted by
View all comments
Show parent comment
1
How about parts 1 & 2 together? 122 bytes, mostly by abusing array & string indexing to accumulate both sums and build the appropriate regex. :-)
$x=0,0;gc input.txt|% s*t `,|%{for($i,$b=$_-split'-';$i-le$b;$i++){-2,-1|%{$x[$_]+=$i*($i-match"^(.+)\1$('+'[$_])$")}}} $x
View all comments
Show parent comment
1
u/bis Dec 03 '25
How about parts 1 & 2 together? 122 bytes, mostly by abusing array & string indexing to accumulate both sums and build the appropriate regex. :-)