From 13f99be2b57472c86b8cabe9a90c9dbacc5aefc6 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Sat, 16 Oct 2021 22:44:44 +0100 Subject: - Tidied up guest contributions by Conor Hoekstra. --- challenge-134/conor-hoekstra/apl/ch-1.apl | 19 +++++++++++++++++++ challenge-134/conor-hoekstra/apl/ch-2.apl | 20 ++++++++++++++++++++ challenge-134/conor-hoekstra/ch-01.apl | 19 ------------------- challenge-134/conor-hoekstra/ch-02.apl | 20 -------------------- 4 files changed, 39 insertions(+), 39 deletions(-) create mode 100644 challenge-134/conor-hoekstra/apl/ch-1.apl create mode 100644 challenge-134/conor-hoekstra/apl/ch-2.apl delete mode 100644 challenge-134/conor-hoekstra/ch-01.apl delete mode 100644 challenge-134/conor-hoekstra/ch-02.apl diff --git a/challenge-134/conor-hoekstra/apl/ch-1.apl b/challenge-134/conor-hoekstra/apl/ch-1.apl new file mode 100644 index 0000000000..c45ca38256 --- /dev/null +++ b/challenge-134/conor-hoekstra/apl/ch-1.apl @@ -0,0 +1,19 @@ +⍝ Solution 1 +pandigital ← +/¯1,((⊢*-∘2)×-∘1),((*⍨-⊢)÷(2*⍨1-⍨⊢)) + +1,pandigital¨1+⍳4 ⍝ 1 2 11 75 694 + +⍝ Solution 2 +pandigital ← { + a ← (*⍨-⊢)⍵ ⍝ ⍵^⍵ - ⍵ + b ← ⍵-1 ⍝ ⍵-1 + c ← (⊢*-∘2)⍵ ⍝ ⍵^(⍵-2) + (a÷b*2)+(b×c)-1 +} + +1,pandigital¨1+⍳4 ⍝ 1 2 11 75 694 + +⍝ Solution 3 +pandigital ← {(⍺=≢∘∪)⍺(⊥⍣¯1)⍵} + +1,{ ⊃⍸⍵∘pandigital¨⍳1000 }¨1+⍳4 ⍝ 1 2 11 75 694 diff --git a/challenge-134/conor-hoekstra/apl/ch-2.apl b/challenge-134/conor-hoekstra/apl/ch-2.apl new file mode 100644 index 0000000000..ca45f28b71 --- /dev/null +++ b/challenge-134/conor-hoekstra/apl/ch-2.apl @@ -0,0 +1,20 @@ +distinctTermCount ← { + ⎕ ← t ← ⍺(∘.×⍥⍳)⍵ + ⎕ ← 'Distinct Terms:',∪,t + ⎕ ← 'Count:',≢∪,t +} + +⍝ Tests + 3 distinctTermCount 3 +1 2 3 +2 4 6 +3 6 9 +Distinct Terms: 1 2 3 4 6 9 +Count: 6 + + 3 distinctTermCount 5 +1 2 3 4 5 +2 4 6 8 10 +3 6 9 12 15 +Distinct Terms: 1 2 3 4 5 6 8 10 9 12 15 +Count: 11 diff --git a/challenge-134/conor-hoekstra/ch-01.apl b/challenge-134/conor-hoekstra/ch-01.apl deleted file mode 100644 index c45ca38256..0000000000 --- a/challenge-134/conor-hoekstra/ch-01.apl +++ /dev/null @@ -1,19 +0,0 @@ -⍝ Solution 1 -pandigital ← +/¯1,((⊢*-∘2)×-∘1),((*⍨-⊢)÷(2*⍨1-⍨⊢)) - -1,pandigital¨1+⍳4 ⍝ 1 2 11 75 694 - -⍝ Solution 2 -pandigital ← { - a ← (*⍨-⊢)⍵ ⍝ ⍵^⍵ - ⍵ - b ← ⍵-1 ⍝ ⍵-1 - c ← (⊢*-∘2)⍵ ⍝ ⍵^(⍵-2) - (a÷b*2)+(b×c)-1 -} - -1,pandigital¨1+⍳4 ⍝ 1 2 11 75 694 - -⍝ Solution 3 -pandigital ← {(⍺=≢∘∪)⍺(⊥⍣¯1)⍵} - -1,{ ⊃⍸⍵∘pandigital¨⍳1000 }¨1+⍳4 ⍝ 1 2 11 75 694 diff --git a/challenge-134/conor-hoekstra/ch-02.apl b/challenge-134/conor-hoekstra/ch-02.apl deleted file mode 100644 index ca45f28b71..0000000000 --- a/challenge-134/conor-hoekstra/ch-02.apl +++ /dev/null @@ -1,20 +0,0 @@ -distinctTermCount ← { - ⎕ ← t ← ⍺(∘.×⍥⍳)⍵ - ⎕ ← 'Distinct Terms:',∪,t - ⎕ ← 'Count:',≢∪,t -} - -⍝ Tests - 3 distinctTermCount 3 -1 2 3 -2 4 6 -3 6 9 -Distinct Terms: 1 2 3 4 6 9 -Count: 6 - - 3 distinctTermCount 5 -1 2 3 4 5 -2 4 6 8 10 -3 6 9 12 15 -Distinct Terms: 1 2 3 4 5 6 8 10 9 12 15 -Count: 11 -- cgit