diff --git a/p17.dyalog b/p17.dyalog new file mode 100644 index 0000000..5695ec5 --- /dev/null +++ b/p17.dyalog @@ -0,0 +1,14 @@ +⎕IO←0 +c←⊃¨p←⊃⎕NGET'p17.txt'1 +p←⍎¨¨'\d+'⎕S'&'¨p +a b←(⌊/,⌈/)∊1↓¨p/⍨c='x' +g←(1+b)1000⍴'' +to←{⍺+⍳⍵-⍺} +{g[⍵[1] to 1+⍵[2];⍵[0]]←'#'}¨p/⍨c='x' +{g[⍵[0];⍵[1] to 1+⍵[2]]←'#'}¨p/⍨c='y' +d←{x y←⍵ ⋄ t←y↓g[;x] ⋄ n←1⍳⍨t∊'#~' ⋄ g[y+⍳n;x]←'|' ⋄ _←f⍣(nk j ⋄ ⍱/t:∇⍵-0 1 ⋄ d¨y,⍨¨t/(i-1)j} +d 500 0 ++/,'|~'∊⍨a↓g ⍝ part 1 ++/,'~'=a↓g ⍝ part 2