Initial commit
This commit is contained in:
commit
ae3c325e43
3 changed files with 31 additions and 0 deletions
5
README.org
Normal file
5
README.org
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
* Dyalog APL Problem Solving Competition 2021
|
||||||
|
|
||||||
|
My solutions for the [[https://www.dyalogaplcompetition.com/][2021 APL Problem Solving Competition]].
|
||||||
|
|
||||||
|
- Phase I: [[phase1.dyalog]]
|
23
phase1.dyalog
Normal file
23
phase1.dyalog
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
:Namespace Phase1
|
||||||
|
⍝ 1: Are You a Bacteria?
|
||||||
|
bacteria←{100×(+/÷≢)⍵∊'GC'}
|
||||||
|
⍝ 2: Index-Of Modified
|
||||||
|
indexof←{(0@((1+≢⍺)∘=))⍺⍳⍵}
|
||||||
|
⍝ 3: Multiplicity
|
||||||
|
multiply←((↓0=∘.|∘,)(/¨)(⊂⊢))
|
||||||
|
⍝ 4: Square Peg, Round Hole
|
||||||
|
squarepeg←{(○-2∘×)4÷⍨⍵*2}
|
||||||
|
⍝ 5: Rect-ify
|
||||||
|
rectify←{⍵[(⌊,⌈)2÷⍨1+≢⍵]}(∪⊢∨⍳) ⍝ only for ⍵>0
|
||||||
|
rectify←{⎕div←1⋄⍵(⊢,÷)⊃⌽((∪⊢∨⍳)∩(⍳⌊*∘0.5))⍵}
|
||||||
|
⍝ 6: Fischer Random Chess
|
||||||
|
fischerchess←{(≠/2|⍸'B'=⍵)∧≠/(⍸'K'=⍵)<⍸'R'=⍵}
|
||||||
|
⍝ 7: Can You Feel the Magic?
|
||||||
|
magic←{1=≢∪,+/↑((⊢⍪1 1∘⍉)¨(⊂,⊂∘⌽∘⍉))⍵}
|
||||||
|
⍝ 8: Time to Make a Difference
|
||||||
|
timetomake←(|-⍥(+/1 60 1440×3↑⌽))
|
||||||
|
⍝ 9: In the Long Run
|
||||||
|
longrun←{⌈/,↑(⌈/∘≢¨⊆⍨)¨2((⊂</),(⊂>/),(⊂=/))⍵}
|
||||||
|
⍝ 10: On the Right Side
|
||||||
|
right←(↑(↑⍨∘-⍨)¨∘⊆)
|
||||||
|
:EndNamespace
|
3
phase2.dyalog
Normal file
3
phase2.dyalog
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
:Namespace Phase2
|
||||||
|
lexf←{∪(-⍺)↑¨,((∘.,⍨)⍣(⌈2⍟1+⍺))⍵}
|
||||||
|
:EndNamespace
|
Loading…
Add table
Add a link
Reference in a new issue