From ae3c325e437577d9ce08b4f9e7d740530efedd69 Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Mon, 23 Oct 2023 10:57:02 +0200 Subject: [PATCH] Initial commit --- README.org | 5 +++++ phase1.dyalog | 23 +++++++++++++++++++++++ phase2.dyalog | 3 +++ 3 files changed, 31 insertions(+) create mode 100644 README.org create mode 100644 phase1.dyalog create mode 100644 phase2.dyalog diff --git a/README.org b/README.org new file mode 100644 index 0000000..1cace15 --- /dev/null +++ b/README.org @@ -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]] diff --git a/phase1.dyalog b/phase1.dyalog new file mode 100644 index 0000000..aaeaadc --- /dev/null +++ b/phase1.dyalog @@ -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 \ No newline at end of file diff --git a/phase2.dyalog b/phase2.dyalog new file mode 100644 index 0000000..08480a5 --- /dev/null +++ b/phase2.dyalog @@ -0,0 +1,3 @@ + :Namespace Phase2 + lexf←{∪(-⍺)↑¨,((∘.,⍨)⍣(⌈2⍟1+⍺))⍵} + :EndNamespace \ No newline at end of file