puzzle_11.dyalog (778B)
1 test ← ⍎ ¨ 10 10 ⍴ '5483143223274585471152645561736141336146635738547841675246452176841721688288113448468485545283751526' 2 input ← ⍎ ¨ 10 10 ⍴ '1443582148655373485114517412468835218864166231726217316566231128178367584235166566773268437381433267' 3 4 f ← 9>⍨⊢ ⍝ boolean matrix of flashes 5 z ← ⊢×~⍤f⍤⊢ ⍝ zero out flashes 6 c ← 100=+/⍤(+⌿=⍥f) ⍝ compare boolean matrices 7 s ← ((+/+⌿⍤⊢) ⌺ 3 3)⍤f⍤⊢ ⍝ sum stencil of flashing neighbours 8 g ← s+⍨1+⊃⍤⊣ ⍝ sum stencil + ⍵ + 1 9 10 Dumbo ← { (⊂ z (⍵g⊢) ⍣ (⊢c⍵g⊢) 1 + ⊃⍵) , ⍺⍺ ⍵ } ⍝ generate next round 11 12 +/+⌿ ⊃ +⌿ 0 = ((⊢ Dumbo) ⍣ 100) ⊂ input ⍝ part 1 13 1 -⍨ 1 ↓ ((1+1↓⊢) Dumbo) ⍣ (0=(+/+⌿⍤⊃⍤⊢)) input 0 ⍝ part 2