aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2021-04-25 22:42:43 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2021-04-25 22:42:43 +0100
commitae93b2c48d785545c94e1d5ae96887322308f969 (patch)
treecbb962818ed706395b0056392686302a8ef291a2
parent83ddffcdf8bd8808a022a9ba66187e929e8d5184 (diff)
downloadperlweeklychallenge-club-ae93b2c48d785545c94e1d5ae96887322308f969.tar.gz
perlweeklychallenge-club-ae93b2c48d785545c94e1d5ae96887322308f969.tar.bz2
perlweeklychallenge-club-ae93b2c48d785545c94e1d5ae96887322308f969.zip
- Added APL solutions by Richard Park.
-rw-r--r--challenge-109/richard-park/apl/ch-1.aplf4
-rw-r--r--challenge-109/richard-park/apl/ch-2.aplf11
2 files changed, 15 insertions, 0 deletions
diff --git a/challenge-109/richard-park/apl/ch-1.aplf b/challenge-109/richard-park/apl/ch-1.aplf
new file mode 100644
index 0000000000..afbbc7078f
--- /dev/null
+++ b/challenge-109/richard-park/apl/ch-1.aplf
@@ -0,0 +1,4 @@
+ ChowlaNumbers←{
+⍝ Sum of divisors of ⍵ except 1 and ⍵
+ +/1↓¯1↓(∪⊢∨⍳)⍵
+ }
diff --git a/challenge-109/richard-park/apl/ch-2.aplf b/challenge-109/richard-park/apl/ch-2.aplf
new file mode 100644
index 0000000000..4154cbc93e
--- /dev/null
+++ b/challenge-109/richard-park/apl/ch-2.aplf
@@ -0,0 +1,11 @@
+ FourSquaresPuzzle←{
+⍝ https://perlweeklychallenge.org/blog/perl-weekly-challenge-109/#TASK1
+⍝ ⍺: Groups of indices of numbers in ⍵ which share squares
+⍝ ⍵: Numbers to be distributed
+ ⍵≢⍥≢∪∊⍺:'Invalid input. There must be enough numbers to distribute'
+⍝ Example:
+⍝ (1 2)(2 3 4)(4 5 6)(6 7) FourSquaresPuzzle ⍳7
+ permutations←p⌷⍨⊂⍸1=≢¨(⊂∪)⍤1+/p←⍺⌷⍤0 99⍤1⊢⍵[pmat≢⍵]
+ selection←(⍴⍴(0∘≠×≠)∘,)↑⍺ ⍝ Mask to select from each matrix in permutations
+ ∊⍤¯1⊢selection⊂⍤(⊢⍤⌿)⍤1⍤99 ¯1⊢permutations
+ }