From 1a7fafa31abcdedf3de43c73c09b1bd9db057c70 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Wed, 5 Dec 2018 09:29:56 +0000 Subject: [PATCH] Day 5 new array solution is much faster than old iterative one. --- p5faster.dyalog | 10 ++++------ p5iterative.dyalog | 4 ---- 2 files changed, 4 insertions(+), 10 deletions(-) delete mode 100644 p5iterative.dyalog diff --git a/p5faster.dyalog b/p5faster.dyalog index 4d45abe..6a3ebd0 100644 --- a/p5faster.dyalog +++ b/p5faster.dyalog @@ -1,7 +1,5 @@ -p←⊃⊃⎕NGET'p5.txt'1 -lcase←819⌶ -b←⌽¨a←⎕A,¨lcase ⎕A -f←{⍵/⍨(⊢⍱¯1⌽⊢)⊃∨/⍺⍷¨⊂⍵} -g←(a∘f b∘f)⍣≡ +p←⎕UCS⊃⊃⎕NGET'p5.txt'1 +f←{⍵/⍨{(⍵,0)⍱0,⍵}⍺=2-/⍵} +g←(32∘f ¯32∘f)⍣≡ ≢q←g p ⍝ part 1 -⌊/{≢g q~⍵,lcase ⍵}¨⎕A ⍝ part 2 +⌊/{≢g q~⍵,32+⍵}¨⎕UCS ⎕A ⍝ part 2 diff --git a/p5iterative.dyalog b/p5iterative.dyalog deleted file mode 100644 index e5dfdd4..0000000 --- a/p5iterative.dyalog +++ /dev/null @@ -1,4 +0,0 @@ -p←⎕UCS⊃⊃⎕NGET'p5.txt'1 -f←{a←⍬ ⋄ _←{32=|⍵-⊃⌽a:a↓⍨←¯1 ⋄ a,←⍵}¨⍵ ⋄ a} -≢q←f p ⍝ part 1 -⌊/{≢f q~⍵,⍵+32}¨⎕UCS ⎕A ⍝ part 2