adventofcode

https://adventofcode.com/
Log | Files | Refs

puzzle_9.apl (314B)


      1 #! /usr/bin/apl --script
      2 
      3 ⎕IO←0 
      4 input← ⎕FIO[49] 'files/9.txt'
      5 
      6 j←⍉9,(⍉9,(⊃{⍎¨(2|⍳2×⍴⍵)⊂2/⍵}¨input),9),9
      7 l←{3 3 ↑ (↑⌽⍵)⌽ (↑⍵)⊖ j} ¨ ⍳2-⍨⍴j
      8 +/{(r + 1) × 4 = +/ (r←↑ 1⊖ 1⌽ c) < (2|⍳9) / 9 ⍴ c←⊃ ⍵ ⌷ l} ¨ (×/2-⍴j) ⍴ ⍳2-⍨⍴j
      9 
     10 )OFF