AdventOfCode/APL/2021/16.apl

12 lines
851 B
APL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

input ,/{42}¨1-('0123456789ABCDEF')¨⎕NGET '../.cache/2021/16' 1
⎕PP 32
read {a b2input[1-a+b]}
rl {i xcread i 1x(x×16)+read(i+1)4~c:(i+5)x(i+5)x}
gv0 {{i cic:i 0 i v xsolve ii vs xsi ci(v+vs)(x,xs)}(+15)(+15+read 15)}
gv1 {{i cc0:i 0 i v xsolve ii vs xsi(c-1)i(v+vs)(x,xs)}(+11)(read 11)}
gv {0=read 1:gv0 (+1)gv1 (+1)}
op {t xt=0:+/xt=1:×/xt=2:/xt=3:/xt=5:(x)>2xt=6:(x)<2xt=7:(x)=2x}
solve {ivread i 3ii+3tread i 3ii+3t=4:{i xi v x}rl i 0i vs xsgv ii(v+vs)(op t xs)}
_ part1 part2 solve 1
part1
part2