advent-of-code/2020/day13/day13.dyalog
2024-11-12 21:46:18 +01:00

18 lines
603 B
APL
Raw 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.

⎕IO0 (⎕FR ⎕PP)1287 34
p⎕NGET'input'1
tp
b¨((1<',x'))1p
b{×/((/))¨(),}b|-t ⍝ Part 1
⍝ https://www.jsoftware.com/papers/50/50_44.htm
xea{(,1 0){0=: -×()÷}(,0 1)}
rlarg cr rarg
m rlarg
n srarg
gcd a bm xea n
lcmm×n÷gcd
clcm|gcd÷(r×b×n)+(s×a×m)
rlcm,c
c','()1p
b¨¨(~('x')¨c)/¨(c),-c
1cr/{x y 0=y:x,y 1:x(x+y)}¨b ⍝ Part 2