From ae93b2c48d785545c94e1d5ae96887322308f969 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Sun, 25 Apr 2021 22:42:43 +0100 Subject: - Added APL solutions by Richard Park. --- challenge-109/richard-park/apl/ch-1.aplf | 4 ++++ challenge-109/richard-park/apl/ch-2.aplf | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 challenge-109/richard-park/apl/ch-1.aplf create mode 100644 challenge-109/richard-park/apl/ch-2.aplf 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 + } -- cgit