commit 1e0598eaf59f0e5824938fbfd436e1359e72ef26
parent 3e38183729dbe4efdc003063cc4d1c3c7d7afd23
Author: mpizzzle <m@michaelpercival.xyz>
Date: Thu, 9 Dec 2021 18:28:24 +0000
minor refactoring (further function refactoring needed)
Diffstat:
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/2021/puzzle_3.apl b/2021/puzzle_3.apl
@@ -9,10 +9,6 @@ y f x × (y← ⌽ (⍳⍴ x) - 1) f ~x← ⊃ ((≢ input) ÷ 2) < +/a ⍝ part
m← { ⍺ ({ (⊃ ⍺ ⌷ (⊃ ((≢ ⍵ ) ÷ 2) > +/⍵ ) { (~ ⍣ ⍺) ⍵ } ¨ (⊂ ⍤1)⍉ ⊃ ⊃ ⍵ ) / ⍵ } ⍣ ((⍴ ⍵ ) > 1)) ⍵ }
n← { ⍺ ({ (⊃ ⍺ ⌷ (⊃ ((≢ ⍵ ) ÷ 2) ≤ +/⍵ ) { (~ ⍣ ⍺) ⍵ } ¨ (⊂ ⍤1)⍉ ⊃ ⊃ ⍵ ) / ⍵ } ⍣ ((⍴ ⍵ ) > 1)) ⍵ }
-s← ⍴ ↑ a
-r← (⌽ (⍳s) - 1)
-o← r f s ⍴ ⊃ ⊃ m/(r + 1),(⊂ a)
-c← r f s ⍴ ⊃ ⊃ n/(r + 1),(⊂ a)
-o × c ⍝ part 2
+(r f s ⍴ ⊃ ⊃ m/(r + 1),(⊂ a)) × (r f s ⍴ ⊃ ⊃ n/(1 + r← (⌽ (⍳s← ⍴ ↑ a) - 1)),(⊂ a)) ⍝ part 2
)OFF