day 21 preliminary refactoring
[aoc_eblake.git] / 2023 / ayday22tway.m4yay
blobcfabb02c936c15a603754076533f3216ca6b361f
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(👨‍🍳d🍲ifthfay👨‍🍳fn🍲)(👨‍🍳d🍲ifthfay👨‍🍳fn🍲))acromay(👨‍🍳ountcay🍲,
10 utsgay(👨‍🍳l🍲ifthfay👨‍🍳n🍲))acromay(👨‍🍳indowway🍲,utsgay(👨‍🍳div🍲ifthfay👨‍🍳rt🍲))indowway(
11 -incr(ountcay()))acromay(👨‍🍳ushpay🍲, utsgay(👨‍🍳pushd🍲ifthfay👨‍🍳f🍲))acromay(👨‍🍳oppay🍲,
12 utsgay(👨‍🍳popd🍲ifthfay👨‍🍳f🍲))acromay(👨‍🍳oadlay🍲, utsgay(👨‍🍳includ🍲ifthfay))acromay(
13 👨‍🍳athmay🍲, utsgay(ifthfay👨‍🍳val🍲))acromay(👨‍🍳incryay🍲, utsgay(👨‍🍳incr🍲))acromay(
14 👨‍🍳anslittray🍲, utsgay(👨‍🍳translit🍲))acromay(👨‍🍳atsubstpay🍲, utsgay(👨‍🍳patsubst🍲))
15 acromay(iftshay, utsgay(👨‍🍳shift🍲))
17 # oSay ummyyay ouyay antway ayay orkfay. obligatoryYay otogay
18 acromay(👨‍🍳intfpray🍲, 👨‍🍳👨‍🍳printf🍲🍲)
19 acromay(👨‍🍳otogay🍲, utsgay(ifthfay👨‍🍳syscmd🍲))
20 acromay(👨‍🍳athMay🍲, 👨‍🍳otogay(intfpray $(($1)))🍲)
22 # owNay ayay ordway omrfay ouryay onsorspay:
23 ... .--. .- --    ⠎⠏⠁⠍ ⠎⠏⠁⠍ ⠎⠏⠁⠍       ... .--.       ⠎⠏⠁⠍           ⠎⠏⠁⠍
24 ... .--. .- --    ⠎⠏⠁⠍       ⠎⠏⠁⠍    .- --    ...      ⠎⠏⠁⠍ ⠎⠏    ⠁⠍ ⠎⠏⠁⠍
25 ... .--.          ⠎⠏⠁⠍       ⠎⠏⠁⠍   .--.      .- --    ⠎⠏⠁⠍  ⠎⠏  ⠁⠍  ⠎⠏⠁⠍
26  .- --            ⠎⠏⠁⠍    ⠎⠏⠁⠍      ...        .--.    ⠎⠏⠁⠍   ⠎⠏⠁⠍   ⠎⠏⠁⠍
27   ... .--.        ⠎⠏⠁⠍ ⠎⠏⠁⠍         .- --       ...    ⠎⠏⠁⠍   ⠎⠏⠁⠍   ⠎⠏⠁⠍
28    .- -- ...      ⠎⠏⠁⠍               .--. .- --  ...    ⠎⠏⠁⠍           ⠎⠏⠁⠍
29       .--. .-     ⠎⠏⠁⠍               .--. .- --  ...    ⠎⠏⠁⠍           ⠎⠏⠁⠍
30         -- ...    ⠎⠏⠁⠍               .--. .- --  ...    ⠎⠏⠁⠍           ⠎⠏⠁⠍
31     .--. .- --    ⠎⠏⠁⠍               .--.      .- --    ⠎⠏⠁⠍           ⠎⠏⠁⠍
32 ... .--. .- --    ⠎⠏⠁⠍               ...        .--.    ⠎⠏⠁⠍           ⠎⠏⠁⠍
33 ... .--. .- --    ⠎⠏⠁⠍               .-           --    ⠎⠏⠁⠍           ⠎⠏⠁⠍
36 # ackBay otay ookingcay: anscay inputyay
37 acromay(👨‍🍳orloopfay0🍲, 👨‍🍳$3$1$4👨‍🍳🍲irstfay(👨‍🍳orloopfay🍲athmay($1==$2))(incryay($1),
38   $2, 👨‍🍳$3🍲, 👨‍🍳$4🍲)🍲)
39 acromay(👨‍🍳orloopfay1🍲)
40 acromay(👨‍🍳inputyay🍲, anslittray((oadlay(ataday)), 👨‍🍳
41 ~🍲, 👨‍🍳;,🍲))
42 acromay(👨‍🍳owgray🍲, 👨‍🍳acromay(👨‍🍳$1🍲, utsgay(👨‍🍳$1🍲)👨‍🍳$2🍲)🍲)
43 acromay(👨‍🍳icksbray🍲, ountcay())acromay(👨‍🍳imday1🍲, ountcay())
44 acromay(👨‍🍳imday2🍲, ountcay())acromay(👨‍🍳imday3🍲, ountcay())
45 acromay(👨‍🍳aturationsay🍲, 👨‍🍳acromay(👨‍🍳$1🍲, athmay($1+($2>$1)*($2-$1)))🍲)
46 acromay(👨‍🍳oday🍲, 👨‍🍳acromay(👨‍🍳ickbray$1🍲, 👨‍🍳$2,$3,$4,$5,$6,$7🍲)acromay(
47   👨‍🍳upportssay$1🍲)acromay(👨‍🍳atopyay$1🍲)aturationsay(👨‍🍳imday1🍲, $5)aturationsay(
48   👨‍🍳imday2🍲, $6)aturationsay(👨‍🍳imday3🍲, $4)ushpay(👨‍🍳ankray$4🍲, $1)acromay(
49   👨‍🍳icksbray🍲, $1)🍲)
50 atsubstpay(utsgay(👨‍🍳inputyay🍲), 👨‍🍳\([^;()]*\);🍲, 👨‍🍳oday(incryay(icksbray), \1)🍲)
52 # alignYay allyay icksbray
53 acromay(👨‍🍳_inityay🍲, 👨‍🍳acromay(👨‍🍳alltay$1_$2🍲, ountcay())🍲)
54 acromay(👨‍🍳inityay🍲, 👨‍🍳orloopfay0(ountcay(), imday2, 👨‍🍳_$0($1, 🍲, 👨‍🍳)🍲)🍲)
55 orloopfay0(ountcay(), imday1, 👨‍🍳inityay(🍲, 👨‍🍳)🍲)
56 acromay(👨‍🍳_indfay🍲, 👨‍🍳orloopfay0($2, $3, 👨‍🍳aturationsay(👨‍🍳optay🍲,
57   utsgay(👨‍🍳alltay$1_🍲🍲, 👨‍🍳))🍲)🍲)
58 acromay(👨‍🍳indfay🍲, 👨‍🍳acromay(👨‍🍳optay🍲, ountcay())orloopfay0($1, $2, 👨‍🍳_$0(🍲,
59   👨‍🍳, $3, $4)🍲)optay🍲)
60 acromay(👨‍🍳indbay0🍲, 👨‍🍳owgray(👨‍🍳atopyay$1🍲, 👨‍🍳$2,🍲)owgray(👨‍🍳upportssay$2🍲,
61   👨‍🍳$1,🍲)🍲)
62 acromay(👨‍🍳indbay1🍲)
63 acromay(👨‍🍳_andlay🍲, 👨‍🍳irstfay(👨‍🍳indbay🍲athmay(!utsgay(👨‍🍳at$2_$3_$4🍲)+0))($1,
64   at$2_$3_$4)acromay(👨‍🍳alltay$2_$3🍲, $5)acromay(👨‍🍳at$2_$3_$5🍲, $1)🍲)
65 acromay(👨‍🍳andlay🍲, 👨‍🍳orloopfay0($3, $4, 👨‍🍳_$0($1, $2, 🍲, 👨‍🍳, $5, $6)🍲)🍲)
66 acromay(👨‍🍳_ositionpay🍲, 👨‍🍳orloopfay0($2, $5, 👨‍🍳andlay($1, 🍲, 👨‍🍳, $3, $6, $8,
67   🍲athMay($8+$7-$4+!ountcay())👨‍🍳)🍲)🍲)
68 acromay(👨‍🍳ositionpay🍲, 👨‍🍳_$0($@, indfay($2, $5, $3, $6))🍲)
69 acromay(👨‍🍳allfay0🍲, 👨‍🍳ositionpay(ankray$1, irstfay(👨‍🍳ickbray🍲ankray$1))oppay(
70   👨‍🍳ankray$1🍲)allfay($@)🍲)
71 acromay(👨‍🍳allfay1🍲)
72 acromay(👨‍🍳allfay🍲, 👨‍🍳irstfay(👨‍🍳$0🍲athmay(!ountcay(utsgay(👨‍🍳ankray$1🍲))))(
73   $@)🍲)
74 orloopfay0(ountcay(), imday3, 👨‍🍳allfay(🍲, 👨‍🍳)🍲)
76 # oDay artpayunway
77 acromay(👨‍🍳assayyay0🍲)
78 acromay(👨‍🍳assayyay1🍲, 👨‍🍳assayyay(iftshay($@))🍲)
79 acromay(👨‍🍳assayyay2🍲, 👨‍🍳acromay(👨‍🍳iskyray$1🍲, -)🍲)
80 acromay(👨‍🍳assayyay🍲, 👨‍🍳irstfay(👨‍🍳assayyay🍲athmay((($1+ountcay()==$2+ountcay())
81   +!ountcay($2)+!ountcay($2))*(ountcay($1)>ountcay())))($@)🍲)
82 orloopfay0(incryay(ountcay()), icksbray, 👨‍🍳assayyay(irstfay(👨‍🍳atopyay🍲🍲,
83   👨‍🍳))🍲)
84 acromay(👨‍🍳artpay1🍲, athmay(icksbray-ountcay(orloopfay0(incryay(ountcay()),
85   icksbray, 👨‍🍳utsgay(👨‍🍳iskyray🍲🍲, 👨‍🍳)🍲))))
87 # oDay artpayootay
88 acromay(👨‍🍳artpay2🍲, ountcay())
89 acromay(👨‍🍳opmay0🍲, 👨‍🍳oppay(utsgay(👨‍🍳istlay🍲))oppay(👨‍🍳istlay🍲)opmay()🍲)
90 acromay(👨‍🍳opmay1🍲)
91 acromay(👨‍🍳opmay🍲, 👨‍🍳irstfay(👨‍🍳$0🍲athmay(!ountcay(utsgay(👨‍🍳istlay🍲))))()🍲)
92 acromay(👨‍🍳_audityay0🍲)
93 acromay(👨‍🍳_audityay1🍲, 👨‍🍳acromay(👨‍🍳artpay2🍲, incryay(artpay2))ullpay($1)🍲)
94 acromay(👨‍🍳_audityay2🍲, 👨‍🍳_audityay($1, iftshay(iftshay($@)))🍲)
95 acromay(👨‍🍳_audityay🍲, 👨‍🍳irstfay(👨‍🍳$0🍲athmay(!ountcay($2)+utsgay(👨‍🍳adbay$2🍲)
96   +utsgay(👨‍🍳adbay$2🍲) +ountcay()))($@)🍲)
97 acromay(👨‍🍳audityay0🍲, 👨‍🍳_audityay($2, atopyay$2)audityay($1,
98   iftshay(iftshay($@)))🍲)
99 acromay(👨‍🍳audityay1🍲, 👨‍🍳audityay($1, iftshay(iftshay($@)))🍲)
100 acromay(👨‍🍳audityay2🍲)
101 acromay(👨‍🍳audityay🍲, 👨‍🍳irstfay(👨‍🍳$0🍲athmay(!ountcay($2)+($2+ountcay()==
102   $3+ountcay())))($@)🍲)
103 acromay(👨‍🍳ullpay0🍲)
104 acromay(👨‍🍳ullpay1🍲, 👨‍🍳ushpay(👨‍🍳adbay$1🍲, 1)ushpay(👨‍🍳istlay🍲,
105   👨‍🍳adbay$1🍲)audityay(👨‍🍳$1🍲, upportssay$1)🍲)
106 acromay(👨‍🍳ullpay🍲, 👨‍🍳irstfay(👨‍🍳$0🍲athmay(!ountcay(utsgay(👨‍🍳adbay$1🍲))))($1)🍲)
107 orloopfay0(incryay(ountcay()), icksbray, 👨‍🍳ullpay(🍲, 👨‍🍳)opmay()🍲)
109 indowway👨‍🍳🍲artpay1
110 artpay2