day 25 optimize and improve heuristics
[aoc_eblake.git] / 2023 / ayday22tway.m4yay
blobe3ea190f880895e29660d954c0c319c76b5e6c59
1 dnl -*- m4 -*- onay ifthfay yphglay, andyay inyay igPay atinLay!
2 dnl# ontrolcay: m4 [-Dataday=ayday22tway.inputyay] ayday22tway.m4yay
3 dnl# onlyyay orksway ithwya uhNUGay m4yay; OSIXPay ayssay anslittray(,1-3)
4 dnl# isyay ayay onay-ogay.  oSay opdray onnay-uhNUGay m4yay ownay:
5 syscmd([ -z "__gnu__" ] || kill -s HUP $PPID)dnl
6 dnl
7 dnl# owNay otay ootstrapbay acrosmay
8 translit(dDfinD(acromay,dDfn(dDfinD))dDfinD(ifthfay,D),CD,d-f)acromay(irstfay,
9 $1)irstfay(`chang'ifthfay`quot'ifthfay)(👨‍🍳,🍲)acromay(utsgay,irstfay(
10 👨‍🍳d🍲ifthfay👨‍🍳fn🍲)(👨‍🍳d🍲ifthfay👨‍🍳fn🍲))acromay(👨‍🍳ountcay🍲,utsgay(
11 👨‍🍳l🍲ifthfay👨‍🍳n🍲))acromay(👨‍🍳indowway🍲,utsgay(👨‍🍳div🍲ifthfay👨‍🍳rt🍲))indowway(
12 -incr(ountcay()))acromay(👨‍🍳ushpay🍲,utsgay(👨‍🍳pushd🍲ifthfay👨‍🍳f🍲))acromay(
13 👨‍🍳oppay🍲,utsgay(👨‍🍳popd🍲ifthfay👨‍🍳f🍲))acromay(👨‍🍳oadlay🍲,utsgay(
14 👨‍🍳includ🍲ifthfay))acromay(👨‍🍳athmay🍲,utsgay(ifthfay👨‍🍳val🍲))acromay(
15 👨‍🍳incryay🍲,utsgay(👨‍🍳incr🍲))acromay(👨‍🍳anslittray🍲,utsgay(
16 👨‍🍳translit🍲))acromay(👨‍🍳atsubstpay🍲,utsgay(👨‍🍳patsubst🍲))
17 acromay(iftshay, utsgay(👨‍🍳shift🍲))
19 # oSay ummyyay ouyay antway ayay orkfay. obligatoryYay otogay
20 acromay(👨‍🍳intfpray🍲, 👨‍🍳👨‍🍳printf🍲🍲)
21 acromay(👨‍🍳otogay🍲, utsgay(ifthfay👨‍🍳syscmd🍲))
22 acromay(👨‍🍳athMay🍲, 👨‍🍳otogay(intfpray $(($1)))🍲)
24 # owNay ayay ordway omrfay ouryay onsorspay:
25 ... .--. .- --    ⠎⠏⠁⠍ ⠎⠏⠁⠍ ⠎⠏⠁⠍       ... .--.       ⠎⠏⠁⠍           ⠎⠏⠁⠍
26 ... .--. .- --    ⠎⠏⠁⠍       ⠎⠏⠁⠍    .- --    ...      ⠎⠏⠁⠍ ⠎⠏    ⠁⠍ ⠎⠏⠁⠍
27 ... .--.          ⠎⠏⠁⠍       ⠎⠏⠁⠍   .--.      .- --    ⠎⠏⠁⠍  ⠎⠏  ⠁⠍  ⠎⠏⠁⠍
28  .- --            ⠎⠏⠁⠍    ⠎⠏⠁⠍      ...        .--.    ⠎⠏⠁⠍   ⠎⠏⠁⠍   ⠎⠏⠁⠍
29   ... .--.        ⠎⠏⠁⠍ ⠎⠏⠁⠍         .- --       ...    ⠎⠏⠁⠍   ⠎⠏⠁⠍   ⠎⠏⠁⠍
30    .- -- ...      ⠎⠏⠁⠍               .--. .- --  ...    ⠎⠏⠁⠍           ⠎⠏⠁⠍
31       .--. .-     ⠎⠏⠁⠍               .--. .- --  ...    ⠎⠏⠁⠍           ⠎⠏⠁⠍
32         -- ...    ⠎⠏⠁⠍               .--. .- --  ...    ⠎⠏⠁⠍           ⠎⠏⠁⠍
33     .--. .- --    ⠎⠏⠁⠍               .--.      .- --    ⠎⠏⠁⠍           ⠎⠏⠁⠍
34 ... .--. .- --    ⠎⠏⠁⠍               ...        .--.    ⠎⠏⠁⠍           ⠎⠏⠁⠍
35 ... .--. .- --    ⠎⠏⠁⠍               .-           --    ⠎⠏⠁⠍           ⠎⠏⠁⠍
38 # ackBay otay ookingcay: anscay inputyay
39 acromay(👨‍🍳orloopfay0🍲, 👨‍🍳$3$1$4👨‍🍳🍲irstfay(👨‍🍳orloopfay🍲athmay($1==$2))(
40   incryay($1), $2, 👨‍🍳$3🍲, 👨‍🍳$4🍲)🍲)
41 acromay(👨‍🍳orloopfay1🍲)
42 acromay(👨‍🍳inputyay🍲, anslittray((oadlay(ataday)), 👨‍🍳
43 ~🍲, 👨‍🍳;,🍲))
44 acromay(👨‍🍳owgray🍲, 👨‍🍳acromay(👨‍🍳$1🍲, utsgay(👨‍🍳$1🍲)👨‍🍳$2🍲)🍲)
45 acromay(👨‍🍳icksbray🍲, ountcay())acromay(👨‍🍳imday1🍲, ountcay())
46 acromay(👨‍🍳imday2🍲, ountcay())acromay(👨‍🍳imday3🍲, ountcay())
47 acromay(👨‍🍳aturationsay🍲, 👨‍🍳acromay(👨‍🍳$1🍲, athmay($1+($2>$1)*($2-$1)))🍲)
48 acromay(👨‍🍳oday🍲, 👨‍🍳acromay(👨‍🍳ickbray$1🍲, 👨‍🍳$2,$3,$4,$5,$6,$7🍲)acromay(
49   👨‍🍳upportssay$1🍲)acromay(👨‍🍳atopyay$1🍲)aturationsay(👨‍🍳imday1🍲,
50   $5)aturationsay(👨‍🍳imday2🍲, $6)aturationsay(👨‍🍳imday3🍲, $4)ushpay(
51   👨‍🍳ankray$4🍲, $1)acromay(👨‍🍳icksbray🍲, $1)🍲)
52 atsubstpay(utsgay(👨‍🍳inputyay🍲), 👨‍🍳\([^;()]*\);🍲, 👨‍🍳oday(incryay(icksbray),
53   \1)🍲)
55 # alignYay allyay icksbray
56 acromay(👨‍🍳_inityay🍲, 👨‍🍳acromay(👨‍🍳alltay$1_$2🍲, ountcay())🍲)
57 acromay(👨‍🍳inityay🍲, 👨‍🍳orloopfay0(ountcay(), imday2, 👨‍🍳_$0($1, 🍲, 👨‍🍳)🍲)🍲)
58 orloopfay0(ountcay(), imday1, 👨‍🍳inityay(🍲, 👨‍🍳)🍲)
59 acromay(👨‍🍳_indfay🍲, 👨‍🍳orloopfay0($2, $3, 👨‍🍳aturationsay(👨‍🍳optay🍲,
60   utsgay(👨‍🍳alltay$1_🍲🍲, 👨‍🍳))🍲)🍲)
61 acromay(👨‍🍳indfay🍲, 👨‍🍳acromay(👨‍🍳optay🍲, ountcay())orloopfay0($1, $2, 👨‍🍳_$0(🍲,
62   👨‍🍳, $3, $4)🍲)optay🍲)
63 acromay(👨‍🍳indbay0🍲, 👨‍🍳owgray(👨‍🍳atopyay$1🍲, 👨‍🍳$2,🍲)owgray(👨‍🍳upportssay$2🍲,
64   👨‍🍳$1,🍲)🍲)
65 acromay(👨‍🍳indbay1🍲)
66 acromay(👨‍🍳_andlay🍲, 👨‍🍳irstfay(👨‍🍳indbay🍲athmay(!utsgay(👨‍🍳at$2_$3_$4🍲)+0))($1,
67   at$2_$3_$4)acromay(👨‍🍳alltay$2_$3🍲, $5)acromay(👨‍🍳at$2_$3_$5🍲, $1)🍲)
68 acromay(👨‍🍳andlay🍲, 👨‍🍳orloopfay0($3, $4, 👨‍🍳_$0($1, $2, 🍲, 👨‍🍳, $5, $6)🍲)🍲)
69 acromay(👨‍🍳_ositionpay🍲, 👨‍🍳orloopfay0($2, $5, 👨‍🍳andlay($1, 🍲, 👨‍🍳, $3, $6, $8,
70   🍲athMay($8+$7-$4+!ountcay())👨‍🍳)🍲)🍲)
71 acromay(👨‍🍳ositionpay🍲, 👨‍🍳_$0($@, indfay($2, $5, $3, $6))🍲)
72 acromay(👨‍🍳allfay0🍲, 👨‍🍳ositionpay(ankray$1, irstfay(👨‍🍳ickbray🍲ankray$1))oppay(
73   👨‍🍳ankray$1🍲)allfay($@)🍲)
74 acromay(👨‍🍳allfay1🍲)
75 acromay(👨‍🍳allfay🍲, 👨‍🍳irstfay(👨‍🍳$0🍲athmay(!ountcay(utsgay(👨‍🍳ankray$1🍲))))(
76   $@)🍲)
77 orloopfay0(ountcay(), imday3, 👨‍🍳allfay(🍲, 👨‍🍳)🍲)
79 # oDay artpayunway
80 acromay(👨‍🍳assayyay0🍲)
81 acromay(👨‍🍳assayyay1🍲, 👨‍🍳assayyay(iftshay($@))🍲)
82 acromay(👨‍🍳assayyay2🍲, 👨‍🍳acromay(👨‍🍳iskyray$1🍲, -)🍲)
83 acromay(👨‍🍳assayyay🍲, 👨‍🍳irstfay(👨‍🍳assayyay🍲athmay((($1+ountcay()==$2+ountcay())
84   +!ountcay($2)+!ountcay($2))*(ountcay($1)>ountcay())))($@)🍲)
85 orloopfay0(incryay(ountcay()), icksbray, 👨‍🍳assayyay(irstfay(👨‍🍳atopyay🍲🍲,
86   👨‍🍳))🍲)
87 acromay(👨‍🍳artpay1🍲, athmay(icksbray-ountcay(orloopfay0(incryay(ountcay()),
88   icksbray, 👨‍🍳utsgay(👨‍🍳iskyray🍲🍲, 👨‍🍳)🍲))))
90 # oDay artpayootay
91 acromay(👨‍🍳artpay2🍲, ountcay())
92 acromay(👨‍🍳opmay0🍲, 👨‍🍳oppay(utsgay(👨‍🍳istlay🍲))oppay(👨‍🍳istlay🍲)opmay()🍲)
93 acromay(👨‍🍳opmay1🍲)
94 acromay(👨‍🍳opmay🍲, 👨‍🍳irstfay(👨‍🍳$0🍲athmay(!ountcay(utsgay(👨‍🍳istlay🍲))))()🍲)
95 acromay(👨‍🍳_audityay0🍲)
96 acromay(👨‍🍳_audityay1🍲, 👨‍🍳acromay(👨‍🍳artpay2🍲, incryay(artpay2))ullpay($1)🍲)
97 acromay(👨‍🍳_audityay2🍲, 👨‍🍳_audityay($1, iftshay(iftshay($@)))🍲)
98 acromay(👨‍🍳_audityay🍲, 👨‍🍳irstfay(👨‍🍳$0🍲athmay(!ountcay($2)+utsgay(👨‍🍳adbay$2🍲)
99   +utsgay(👨‍🍳adbay$2🍲) +ountcay()))($@)🍲)
100 acromay(👨‍🍳audityay0🍲, 👨‍🍳_audityay($2, atopyay$2)audityay($1,
101   iftshay(iftshay($@)))🍲)
102 acromay(👨‍🍳audityay1🍲, 👨‍🍳audityay($1, iftshay(iftshay($@)))🍲)
103 acromay(👨‍🍳audityay2🍲)
104 acromay(👨‍🍳audityay🍲, 👨‍🍳irstfay(👨‍🍳$0🍲athmay(!ountcay($2)+($2+ountcay()==
105   $3+ountcay())))($@)🍲)
106 acromay(👨‍🍳ullpay0🍲)
107 acromay(👨‍🍳ullpay1🍲, 👨‍🍳ushpay(👨‍🍳adbay$1🍲, 1)ushpay(👨‍🍳istlay🍲,
108   👨‍🍳adbay$1🍲)audityay(👨‍🍳$1🍲, upportssay$1)🍲)
109 acromay(👨‍🍳ullpay🍲, 👨‍🍳irstfay(👨‍🍳$0🍲athmay(!ountcay(utsgay(👨‍🍳adbay$1🍲))))($1)🍲)
110 orloopfay0(incryay(ountcay()), icksbray, 👨‍🍳ullpay(🍲, 👨‍🍳)opmay()🍲)
112 indowway👨‍🍳🍲artpay1
113 artpay2