diff options
| author | Conor Hoekstra <codereport@outlook.com> | 2021-10-16 16:40:34 -0400 |
|---|---|---|
| committer | Conor Hoekstra <codereport@outlook.com> | 2021-10-16 16:40:34 -0400 |
| commit | ba0b574afb254e4f88609f731a8bc53d58ebb65f (patch) | |
| tree | 145118802cc387a3aec1d43e4063acfac36d98e0 | |
| parent | 78cc5db60b6a54cd365b67b17013b72db7ed4268 (diff) | |
| download | perlweeklychallenge-club-ba0b574afb254e4f88609f731a8bc53d58ebb65f.tar.gz perlweeklychallenge-club-ba0b574afb254e4f88609f731a8bc53d58ebb65f.tar.bz2 perlweeklychallenge-club-ba0b574afb254e4f88609f731a8bc53d58ebb65f.zip | |
Week 134
| -rw-r--r-- | challenge-134/conor-hoekstra/ch-01.apl | 19 | ||||
| -rw-r--r-- | challenge-134/conor-hoekstra/ch-02.apl | 20 |
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 |
