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

7 lines
499 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.

⎕io0
p','()¨⎕nget'input.txt'1
segment{x y 'R'=:{x y+}¨1,(1+1),1 'L'=:{x y+}¨1,-(1+1),1 'D'=:{x y+}¨1,-1,1+1 'U'=:{x y+}¨1,1,1+1}
path{x0 0 1x{x,(x) segment }¨}
/+/(path 0p) path 1p ⍝ part 1
c(path 0p)path 1p
2+/((path 0p)c)+(path 1p)c ⍝ part 2