Dyalog APL Problem Solving Competition - My Solutions


2023 p3: Caesar Salad - APL Competition

{(⍺⌽⎕A,' ')[⎕A⍳⍵]}

2023 p4: Like a Version - APL Competition

{×+/(⍺(×-)⍵)× ⌽10*⍳3}

2023 p5: Risky Business - APL Competition

{n ← (≢⍺)⌊(≢⍵) ⋄ s←+/(n↑⍺)≤(n↑⍵) ⋄ s,n-s}

2023 p6: Key:Value - APL Competition

{p←{(⍺≠⍵)⊆⍵} ⋄ ↑⊢(2⊃⍺)p¨(⊃⍺)p ⍵}
{p←≠⊆⊢ ⋄ ↑⊢(2⊃⍺)p¨(⊃⍺)p ⍵}

2013 P1: Seems a Bit Odd To Me - APL Practice Problems

{⎕IO ← 0 ⋄ run←⍳⍵×2 ⋄ (2|run)/run}
{run←⍳2×⍵ ⋄ (2|run)/run}
{⍸2|⍳2×⍵}

2013 P3: What Is In a Word - APL Practice Problems

{≢(' '≠⍵)⊆'',⍵}
{≢(' '≠⍵)⊆,⍵}

2013 P4: Keeping Things In Balance - APL Practice Problems

{m ← (1 ¯1 0)[('()'⍳' ',⍵)] ⋄ ∧/0=(+/⊃¯1={ ⍺, ⍺ + ⍵}/m)(+/m)}

{m ← (1 ¯1 0)['()'⍳' ',⍵] ⋄ ∧/0=(+/¯1=+\m)(+/m)}

{m ← (1 ¯1 0)['()'⍳' ',⍵] ⋄ ^/(0≤+\m)∧(0=+/m)}

2013 P6: Home On The Range - APL Practice Problems

{⌈/,⍵-⌊/,⍵}

(⌈/-⌊/),

2013 P9: It Is a Moving Experience - APL Practice Problems

{r←,{⍬(⊣⍣(⊃⍺≠0))(+/⍵÷≢⍵)}⌺⍺⊢⍵ ⋄ (r≠0)/r}