Initial commit
This commit is contained in:
commit
f242d2b0df
420 changed files with 62521 additions and 0 deletions
7
2019/day03/day03.dyalog
Normal file
7
2019/day03/day03.dyalog
Normal file
|
@ -0,0 +1,7 @@
|
|||
⎕io←0
|
||||
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←{x←⊂0 0 ⋄ 1↓x⊣{x,←(⊃⌽x) segment ⍵}¨⍵}
|
||||
⌊/+/↑(path ⊃0⌷p) ∩ path ⊃1⌷p ⍝ part 1
|
||||
c←(path ⊃0⌷p)∩path ⊃1⌷p
|
||||
2+⌊/((path ⊃0⌷p)⍳c)+(path ⊃1⌷p)⍳c ⍝ part 2
|
Loading…
Add table
Add a link
Reference in a new issue