From bb7d6ccc65c6c90833ef016474053656b99111de Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Tue, 5 Jul 2022 21:07:58 -0400 Subject: Week 172 in APL --- challenge-172/conor-hoekstra/ch-1.apl | 17 +++++++++++++++++ challenge-172/conor-hoekstra/ch-2.apl | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 challenge-172/conor-hoekstra/ch-1.apl create mode 100644 challenge-172/conor-hoekstra/ch-2.apl diff --git a/challenge-172/conor-hoekstra/ch-1.apl b/challenge-172/conor-hoekstra/ch-1.apl new file mode 100644 index 0000000000..30f0e454b4 --- /dev/null +++ b/challenge-172/conor-hoekstra/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/ch-2.apl b/challenge-172/conor-hoekstra/ch-2.apl new file mode 100644 index 0000000000..9ae2d37f2a --- /dev/null +++ b/challenge-172/conor-hoekstra/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 -- cgit