Advent of Code 2025

d07/part1: simplify counting code to only handle up to 4 digits as that's all we need

+4 -8
+4 -8
d07/part1.sed
··· 13 13 : a; s/aaaaaaaaaa/b/g; t b; b loop 14 14 : b; s/bbbbbbbbbb/c/g; t c; b loop 15 15 : c; s/cccccccccc/d/g; t d; b loop 16 - : d; s/dddddddddd/e/g; t e; b loop 17 - : e; s/eeeeeeeeee/f/g; t f; b loop 18 - : f; s/ffffffffff/g/g; t g; b loop 19 - : g; s/gggggggggg/h/g; t h; b loop 20 - : h; s/hhhhhhhhhh//g 16 + : d; s/dddddddddd//g 21 17 : loop 22 - /a/! s/[b-h]*/&0/ 18 + /a/! s/[b-d]*/&0/ 23 19 s/aaaaaaaaa/9/ 24 20 s/aaaaaaaa/8/ 25 21 s/aaaaaaa/7/ ··· 31 27 s/a/1/ 32 28 : next 33 29 y/bcdefgh/abcdefg/ 34 - /[a-h]/ b loop 30 + /[a-d]/ b loop 35 31 # on the last line, print out the answer 36 32 $p 37 33 ··· 52 48 s/D/|/g # replace the intermediate "D" marker we used in the loop with '|' 53 49 s/.*\n// # get rid of the first line in the current pair 54 50 H # put the line in hold space 55 - b outer # and loop 51 + b outer # and loop