diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-09-01 13:44:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-01 13:44:00 +0100 |
| commit | 6a75690bb1b4d8222f94c9b37f9644f5a61bd562 (patch) | |
| tree | e04e7015eb41f2ff2ba3a7a118d8bc8777924650 | |
| parent | ee004ee57f41143b6bd96d76f417adac30d3d2de (diff) | |
| parent | 4c634e374ac3109df97be2a475d4681d0a0b2b4b (diff) | |
| download | perlweeklychallenge-club-6a75690bb1b4d8222f94c9b37f9644f5a61bd562.tar.gz perlweeklychallenge-club-6a75690bb1b4d8222f94c9b37f9644f5a61bd562.tar.bz2 perlweeklychallenge-club-6a75690bb1b4d8222f94c9b37f9644f5a61bd562.zip | |
Merge pull request #12607 from rikedyp/master
week 337 in APL
| -rw-r--r-- | challenge-337/richard-park/apl/OddMatrix.aplf | 30 | ||||
| -rw-r--r-- | challenge-337/richard-park/apl/SmallerThanCurrent.aplf | 13 |
2 files changed, 43 insertions, 0 deletions
diff --git a/challenge-337/richard-park/apl/OddMatrix.aplf b/challenge-337/richard-park/apl/OddMatrix.aplf new file mode 100644 index 0000000000..dbd1b62e61 --- /dev/null +++ b/challenge-337/richard-park/apl/OddMatrix.aplf @@ -0,0 +1,30 @@ + OddMatrix←{ + ⎕IO←0 + OM←{ + (row col locations)←⍵ ⎕VGET'row' 'col' 'locations' + mat←row col⍴0 + ⊃{(r c)←⍺ ⋄ 1+@c⍤1⊢1+@r⊢⍵}/locations,⊂mat + } + OM ⍵ + +⍝ Tests + Assert←{⍺←'Assertion failure' ⋄ 0∊⍵:⍺ ⎕SIGNAL 8 ⋄ shy←0} + _←Assert [1 3 1 + 1 3 1] ≡ OM(row:2 ⋄ col:3 ⋄ locations:(0 1 ⋄ 1 1)) + + _←Assert [2 2 + 2 2] ≡ OM(row:2 ⋄ col:2 ⋄ locations:(1 1 ⋄ 0 0)) + + _←Assert [2 2 2 + 2 2 2 + 2 2 2] ≡ OM(row:3 ⋄ col:3 ⋄ locations:(0 0 ⋄ 1 2 ⋄ 2 1)) + + _←Assert [ ⋄ 2 2 3 2 3] ≡ OM(row:1 ⋄ col:5 ⋄ locations:(0 2 ⋄ 0 4)) + + _←Assert [3 3 + 3 3 + 3 3 + 3 3] ≡ OM(row:4 ⋄ col:2 ⋄ locations:(1 0 ⋄ 3 1 ⋄ 2 0 ⋄ 0 1)) + + 'All tests passed.' + } diff --git a/challenge-337/richard-park/apl/SmallerThanCurrent.aplf b/challenge-337/richard-park/apl/SmallerThanCurrent.aplf new file mode 100644 index 0000000000..f5d5a7a4e6 --- /dev/null +++ b/challenge-337/richard-park/apl/SmallerThanCurrent.aplf @@ -0,0 +1,13 @@ + SmallerThanCurrent←{ + STC←{¯1++⌿∘.≤⍨⍵} + STC ⍵ + +⍝ Tests + Assert←{⍺←'Assertion failure' ⋄ 0∊⍵:⍺ ⎕SIGNAL 8 ⋄ shy←0} + _←Assert 2 1 0 3≡STC 6 5 4 8 + _←Assert 3 3 3 3≡STC 7 7 7 7 + _←Assert 4 3 2 1 0≡STC 5 4 3 2 1 + _←Assert 1 2 4 0 3≡STC ¯1 0 3 ¯2 1 + _←Assert 1 3 3 4 1≡STC 0 1 1 2 0 + 'All tests passed.' + } |
