From 3bed3ac4af62370aeb10fab7f962f5eb3b2eadc5 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Tue, 11 Dec 2018 15:17:00 +0000 Subject: [PATCH] Day 11 shorter and faster with n-wise reduction. --- p11nwise.dyalog | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 p11nwise.dyalog diff --git a/p11nwise.dyalog b/p11nwise.dyalog new file mode 100644 index 0000000..7127af9 --- /dev/null +++ b/p11nwise.dyalog @@ -0,0 +1,5 @@ +⎕IO←1 +p←⍎⊃⊃⎕NGET'p11.txt'1 +g←{r y←10 0+⍵ ⋄ ¯5+10|⌊100÷⍨r×p+y×r}¨⍳300 300 ⍝ grid +⊃⍸{⍵=⌈/,⍵}3+/3+⌿g ⍝ part 1 +1↓{(⊃⍒⍵)⌷⍵}↑1{0>m←⌈/,t←⍺+/⍺+⌿g:⍵ ⋄ (⍺+1)∇⍵,⊂m,(⊃⍸m=t),⍺}⍬ ⍝ part 2