From 84544264c064b74f4abade23888062bec99b09d0 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Wed, 6 Jul 2022 22:10:23 +0100 Subject: - Added guest contributions by Conor Hoekstra. --- challenge-172/conor-hoekstra/apl/ch-1.apl | 17 +++++++++++++++++ challenge-172/conor-hoekstra/apl/ch-2.apl | 16 ++++++++++++++++ challenge-172/conor-hoekstra/ch-1.apl | 17 ----------------- challenge-172/conor-hoekstra/ch-2.apl | 16 ---------------- 4 files changed, 33 insertions(+), 33 deletions(-) create mode 100644 challenge-172/conor-hoekstra/apl/ch-1.apl create mode 100644 challenge-172/conor-hoekstra/apl/ch-2.apl delete mode 100644 challenge-172/conor-hoekstra/ch-1.apl delete mode 100644 challenge-172/conor-hoekstra/ch-2.apl diff --git a/challenge-172/conor-hoekstra/apl/ch-1.apl b/challenge-172/conor-hoekstra/apl/ch-1.apl new file mode 100644 index 0000000000..30f0e454b4 --- /dev/null +++ b/challenge-172/conor-hoekstra/apl/ch-1.apl @@ -0,0 +1,17 @@ +)load dfns + +primePartitions ← { + p ← ⍸1 pco ⍳⍵ ⍝ primes + c ← p[⍺ cmat ≢p] ⍝ combiations + (↓c)/⍨⍵=+/c +} + +⍝ Tests + 2 primePartitions 18 +┌────┬────┐ +│5 13│7 11│ +└────┴────┘ + 3 primePartitions 19 +┌──────┐ +│3 5 11│ +└──────┘ \ No newline at end of file diff --git a/challenge-172/conor-hoekstra/apl/ch-2.apl b/challenge-172/conor-hoekstra/apl/ch-2.apl new file mode 100644 index 0000000000..9ae2d37f2a --- /dev/null +++ b/challenge-172/conor-hoekstra/apl/ch-2.apl @@ -0,0 +1,16 @@ +min ← ⌊/ +avg ← +/÷≢ +max ← ⌈/ + +percentile ← { + i ← 100÷⍨⍺ׯ1+≢⍵ ⍝ index + avg ⍵[1+(⌈,⌊)i] +} + +fiveNumSummary ← min,25∘percentile,avg,75∘percentile,max + +⍝ Tests + fiveNumSummary 0 0 1 2 63 61 27 13 +0 0.5 20.875 44 63 + fiveNumSummary ⍳5 +1 2 3 4 5 diff --git a/challenge-172/conor-hoekstra/ch-1.apl b/challenge-172/conor-hoekstra/ch-1.apl deleted file mode 100644 index 30f0e454b4..0000000000 --- a/challenge-172/conor-hoekstra/ch-1.apl +++ /dev/null @@ -1,17 +0,0 @@ -)load dfns - -primePartitions ← { - p ← ⍸1 pco ⍳⍵ ⍝ primes - c ← p[⍺ cmat ≢p] ⍝ combiations - (↓c)/⍨⍵=+/c -} - -⍝ Tests - 2 primePartitions 18 -┌────┬────┐ -│5 13│7 11│ -└────┴────┘ - 3 primePartitions 19 -┌──────┐ -│3 5 11│ -└──────┘ \ No newline at end of file diff --git a/challenge-172/conor-hoekstra/ch-2.apl b/challenge-172/conor-hoekstra/ch-2.apl deleted file mode 100644 index 9ae2d37f2a..0000000000 --- a/challenge-172/conor-hoekstra/ch-2.apl +++ /dev/null @@ -1,16 +0,0 @@ -min ← ⌊/ -avg ← +/÷≢ -max ← ⌈/ - -percentile ← { - i ← 100÷⍨⍺ׯ1+≢⍵ ⍝ index - avg ⍵[1+(⌈,⌊)i] -} - -fiveNumSummary ← min,25∘percentile,avg,75∘percentile,max - -⍝ Tests - fiveNumSummary 0 0 1 2 63 61 27 13 -0 0.5 20.875 44 63 - fiveNumSummary ⍳5 -1 2 3 4 5 -- cgit