diff options
Diffstat (limited to 'challenge-308/richard-park')
| -rw-r--r-- | challenge-308/richard-park/apl/CountCommon.aplf | 10 | ||||
| -rw-r--r-- | challenge-308/richard-park/apl/DecodeXOR.aplf | 15 |
2 files changed, 25 insertions, 0 deletions
diff --git a/challenge-308/richard-park/apl/CountCommon.aplf b/challenge-308/richard-park/apl/CountCommon.aplf new file mode 100644 index 0000000000..ac2d5a17e2 --- /dev/null +++ b/challenge-308/richard-park/apl/CountCommon.aplf @@ -0,0 +1,10 @@ + CountCommon←{ +⍝ Can be defined as the 2-train atop + CountCommon←≢∩ +⍝ Literally "count the intersection" +⍝ ≢ ∩ +⍝ Example +⍝ 'perl' 'weekly' 'challenge' (≢∩) 'raku' 'weekly' 'challenge' +⍝ 2 + ≢⍺∩⍵ + } diff --git a/challenge-308/richard-park/apl/DecodeXOR.aplf b/challenge-308/richard-park/apl/DecodeXOR.aplf new file mode 100644 index 0000000000..a2c2cb7b2b --- /dev/null +++ b/challenge-308/richard-park/apl/DecodeXOR.aplf @@ -0,0 +1,15 @@ + DecodeXOR←{ +⍝ ⍺: initial +⍝ ⍵: encoded sequence +⍝ ←: original array that produced ⍵ +⍝ ⍵ ← 2{2⊥≠/2⊥⍣¯1⊢⍵}/original + 0∊⍴⍵:⍺ + nxt←2⊥≠/2⊥⍣¯1⊢⍺,⊃⍵ + ⍺,nxt ∇ 1↓⍵ + +⍝ Examples: +⍝ 1 DecodeXOR 1 2 3 +⍝ 1 0 2 1 +⍝ 4 DecodeXOR 6 2 7 3 +⍝ 4 2 0 7 4 + } |
