diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-07-06 22:08:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-06 22:08:18 +0100 |
| commit | 4f23b35692b013f828d53554eee47ba033f5bbd3 (patch) | |
| tree | a41baf91cf514b1b56b061815defeb3326efb1f3 | |
| parent | 00b9b1eb810de9662143dc161b33aa2759ea6c87 (diff) | |
| parent | bb7d6ccc65c6c90833ef016474053656b99111de (diff) | |
| download | perlweeklychallenge-club-4f23b35692b013f828d53554eee47ba033f5bbd3.tar.gz perlweeklychallenge-club-4f23b35692b013f828d53554eee47ba033f5bbd3.tar.bz2 perlweeklychallenge-club-4f23b35692b013f828d53554eee47ba033f5bbd3.zip | |
Merge pull request #6397 from codereport/master
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 |
