From 4631855e6b3f1f0e731ab8db96e1aabb1576969d Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Fri, 14 Dec 2018 15:36:56 +0000 Subject: [PATCH] Try to go faster by batching calls to a simplified nxt function. --- p14fast.dyalog | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 p14fast.dyalog diff --git a/p14fast.dyalog b/p14fast.dyalog new file mode 100644 index 0000000..53d1251 --- /dev/null +++ b/p14fast.dyalog @@ -0,0 +1,12 @@ +⎕IO←0 +input←⍎⊃⊃⎕NGET'p14.txt'1 +scores←3 7 + +nxt←{⍵+1+tmp,←scores[⍵]} +super←{tmp∘←⍬ ⋄ (≢scores)|(scores,←∊(t<10)↓¨↓⍉10 10⊤t←+/(0.5×≢tmp)2⍴tmp)⊢nxt⍣(1+⌊10÷⍨¯1+(≢scores)-⌈/⍵)⊢⍵}⍣4 +pos←super⍣{input<¯10+≢scores}0 1 +∊⍕¨r←10↑input↓scores ⍝ part 1 + +match←⍎¨⍕input +{}super⍣{∨/match⍷scores}pos +⊃⍸match⍷scores ⍝ part 2