diff options
| author | Conor Hoekstra <codereport@outlook.com> | 2022-07-05 21:07:58 -0400 |
|---|---|---|
| committer | Conor Hoekstra <codereport@outlook.com> | 2022-07-05 21:07:58 -0400 |
| commit | bb7d6ccc65c6c90833ef016474053656b99111de (patch) | |
| tree | f3cd99a82666da262077b70f7b3e6c8aab230fd9 | |
| parent | 342f91d2a399b2479096619a32de666787eb99af (diff) | |
| download | perlweeklychallenge-club-bb7d6ccc65c6c90833ef016474053656b99111de.tar.gz perlweeklychallenge-club-bb7d6ccc65c6c90833ef016474053656b99111de.tar.bz2 perlweeklychallenge-club-bb7d6ccc65c6c90833ef016474053656b99111de.zip | |
Week 172 in APL
| -rw-r--r-- | challenge-172/conor-hoekstra/ch-1.apl | 17 | ||||
| -rw-r--r-- | challenge-172/conor-hoekstra/ch-2.apl | 16 |
2 files changed, 33 insertions, 0 deletions
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 |
