diff options
| author | RikedyP <rikedyp@gmail.com> | 2025-10-27 14:58:48 +0000 |
|---|---|---|
| committer | RikedyP <rikedyp@gmail.com> | 2025-10-27 14:58:48 +0000 |
| commit | 734114fe0aef9d21b97bcfb9168b6ef700003526 (patch) | |
| tree | f3e64992cddd1fc3a981bc46f2ef1a12439fc997 | |
| parent | 9b1eba54d5e59d05df44f336120a6a03be62a645 (diff) | |
| download | perlweeklychallenge-club-734114fe0aef9d21b97bcfb9168b6ef700003526.tar.gz perlweeklychallenge-club-734114fe0aef9d21b97bcfb9168b6ef700003526.tar.bz2 perlweeklychallenge-club-734114fe0aef9d21b97bcfb9168b6ef700003526.zip | |
week 345 in APL
| -rw-r--r-- | challenge-345/richard-park/apl/LastVisitor.aplf | 16 | ||||
| -rw-r--r-- | challenge-345/richard-park/apl/PeakPositions.aplf | 11 |
2 files changed, 27 insertions, 0 deletions
diff --git a/challenge-345/richard-park/apl/LastVisitor.aplf b/challenge-345/richard-park/apl/LastVisitor.aplf new file mode 100644 index 0000000000..c520e95529 --- /dev/null +++ b/challenge-345/richard-park/apl/LastVisitor.aplf @@ -0,0 +1,16 @@ + LastVisitor←{ + ⎕IO←0 + LV←{ + s←⌽⍵⌿⍨0<⍵ ⍝ Seen is reverse of positive integers + i←⍳∘≢¨⊆⍨¯1=⍵ ⍝ How many ¯1s in a row seen so far? + i←∊s≢⍛⌊i+⌽⍳≢i ⍝ Offset by how many groups of ¯1s seen and cap at how many +ve ints seen so far + (s,¯1)[i] ⍝ seen[x] or ¯1 + } +⍝ Tests + 5 ¯1≢LV 5 ¯1 ¯1:∘∘∘ + 7 3 ¯1≢LV 3 7 ¯1 ¯1 ¯1:∘∘∘ + 2 4 2≢LV 2 ¯1 4 ¯1 ¯1:∘∘∘ + 20 30 20≢LV 10 20 ¯1 30 ¯1 ¯1:∘∘∘ + ¯1 ¯1 5≢LV ¯1 ¯1 5 ¯1:∘∘∘ + 'All tests passed.' + } diff --git a/challenge-345/richard-park/apl/PeakPositions.aplf b/challenge-345/richard-park/apl/PeakPositions.aplf new file mode 100644 index 0000000000..a7da9a2ec6 --- /dev/null +++ b/challenge-345/richard-park/apl/PeakPositions.aplf @@ -0,0 +1,11 @@ + PeakPositions←{ + ⎕IO←0 + PP←{⍸1 ¯1⍷1,ׯ2-/⍵} +⍝ Tests + 1,⍛≢PP 1 3 2:∘∘∘ + 2,⍛≢PP 2 4 6 5 3:∘∘∘ + 2 4≢PP 1 2 3 2 4 1:∘∘∘ + 0,⍛≢PP 5 3 1:∘∘∘ ⍝ I think result should be an empty list + 1 3 5≢PP 1 5 1 5 1 5 1:∘∘∘ + 'All tests passed.' + } |
