aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRikedyP <rikedyp@gmail.com>2025-09-01 13:25:22 +0100
committerRikedyP <rikedyp@gmail.com>2025-09-01 13:25:22 +0100
commit4c634e374ac3109df97be2a475d4681d0a0b2b4b (patch)
treec84d6e98d49a81323d9f54e675221d350a61ee72
parente80c93c27044ee16a834a9ee64a0087c1c7d0b1d (diff)
downloadperlweeklychallenge-club-4c634e374ac3109df97be2a475d4681d0a0b2b4b.tar.gz
perlweeklychallenge-club-4c634e374ac3109df97be2a475d4681d0a0b2b4b.tar.bz2
perlweeklychallenge-club-4c634e374ac3109df97be2a475d4681d0a0b2b4b.zip
week 337 in APL
-rw-r--r--challenge-337/richard-park/apl/OddMatrix.aplf30
-rw-r--r--challenge-337/richard-park/apl/SmallerThanCurrent.aplf13
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.'
+ }