aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Smith <js5@sanger.ac.uk>2022-07-05 23:02:01 +0100
committerGitHub <noreply@github.com>2022-07-05 23:02:01 +0100
commit9fc665f377d858e0304a703ddc9542cc0c325bd3 (patch)
tree48cbfa0cfa20ace1f878553496e0a2e1cc5ae2dc
parentd2d14988c1d6c06df953ae3f49d8caf3f419b315 (diff)
downloadperlweeklychallenge-club-9fc665f377d858e0304a703ddc9542cc0c325bd3.tar.gz
perlweeklychallenge-club-9fc665f377d858e0304a703ddc9542cc0c325bd3.tar.bz2
perlweeklychallenge-club-9fc665f377d858e0304a703ddc9542cc0c325bd3.zip
Update README.md
-rw-r--r--challenge-172/james-smith/README.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-172/james-smith/README.md b/challenge-172/james-smith/README.md
index 6cd02905cc..7fe8ecdb67 100644
--- a/challenge-172/james-smith/README.md
+++ b/challenge-172/james-smith/README.md
@@ -42,6 +42,21 @@ sub partition {
**Note** we add a `0` to `@_` so that if (in the first call) `@_` only has two numbers `$p` is set to zero.
+### Only one partition
+
+If you only wish to get **a** partition then we simply tweak the code to have a return in the inner map - to return the entry if we find it!
+
+```perl
+sub first_partition {
+ my ( $m, $n, $p ) = ( @_, 0 );
+ $n > 1
+ ? map { $p = $_;
+ map { return [ $p, @{$_} ] } first_partition( $m-$p, $n-1, $p )
+ } @{ primes $p+1, int( ( $m - $n/2 + 1/2 ) / $n ) }
+ : $m > $p && is_prime $m ? [ $m ] : ();
+}
+```
+
# Task 2 - Five number summary
***You are given an array of integers. Write a script to compute the five-number summary of the given set of integers. (min,lower-quartile,median,upper-quarile,max)***