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