aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-10-16 22:41:33 +0100
committerGitHub <noreply@github.com>2021-10-16 22:41:33 +0100
commitb7c7b5d535959b3c4e95fc21604434acbe5499f7 (patch)
treee393fcbd5225a441efd6d61c8534cafa090f538c
parent144c7f9f12c753eaa1f894305cb57189aba396d0 (diff)
parentba0b574afb254e4f88609f731a8bc53d58ebb65f (diff)
downloadperlweeklychallenge-club-b7c7b5d535959b3c4e95fc21604434acbe5499f7.tar.gz
perlweeklychallenge-club-b7c7b5d535959b3c4e95fc21604434acbe5499f7.tar.bz2
perlweeklychallenge-club-b7c7b5d535959b3c4e95fc21604434acbe5499f7.zip
Merge pull request #5036 from codereport/master
APL Solutions to Week 134
-rw-r--r--challenge-134/conor-hoekstra/ch-01.apl19
-rw-r--r--challenge-134/conor-hoekstra/ch-02.apl20
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-134/conor-hoekstra/ch-01.apl b/challenge-134/conor-hoekstra/ch-01.apl
new file mode 100644
index 0000000000..c45ca38256
--- /dev/null
+++ b/challenge-134/conor-hoekstra/ch-01.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/ch-02.apl b/challenge-134/conor-hoekstra/ch-02.apl
new file mode 100644
index 0000000000..ca45f28b71
--- /dev/null
+++ b/challenge-134/conor-hoekstra/ch-02.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