aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Ferrari <fluca1978@gmail.com>2020-06-29 13:48:10 +0200
committerLuca Ferrari <fluca1978@gmail.com>2020-06-29 13:48:10 +0200
commit9c185dffa7f9568cad642076729b93d3e1011168 (patch)
tree7a80ee1b6a184f46833eb913d734fc322f1d8b11
parent14e647fc20118e2813d7e3aa3b31af54677b6aa5 (diff)
downloadperlweeklychallenge-club-9c185dffa7f9568cad642076729b93d3e1011168.tar.gz
perlweeklychallenge-club-9c185dffa7f9568cad642076729b93d3e1011168.tar.bz2
perlweeklychallenge-club-9c185dffa7f9568cad642076729b93d3e1011168.zip
Fix boundaries.
-rw-r--r--challenge-067/luca-ferrari/raku/ch-1.p63
1 files changed, 2 insertions, 1 deletions
diff --git a/challenge-067/luca-ferrari/raku/ch-1.p6 b/challenge-067/luca-ferrari/raku/ch-1.p6
index a408701f34..ed10fbdcee 100644
--- a/challenge-067/luca-ferrari/raku/ch-1.p6
+++ b/challenge-067/luca-ferrari/raku/ch-1.p6
@@ -6,7 +6,7 @@
# Every combination should be sorted i.e. [2,3] is valid combination but [3,2] is not.
-sub MAIN( Int :$m where { $m > 2 } = 5,
+sub MAIN( Int :$m where { 10 > $m > 2 } = 5,
Int :$n where { $n < $m } = 2 ) {
# found combinations
@@ -16,6 +16,7 @@ sub MAIN( Int :$m where { $m > 2 } = 5,
for ( 1 x $n ).Int ^..^ ( $m x $n ).Int {
my @digits = $_.comb;
next if @digits.elems != $n;
+ next if @digits.grep( * > $m );
my $ok = True;
$ok = False if ( @digits[ $_ ] >= @digits[ $_ + 1 ] ) for 0 ..^ @digits.elems - 1;
@combinations.push: @digits if $ok;