aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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