From 9c185dffa7f9568cad642076729b93d3e1011168 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 29 Jun 2020 13:48:10 +0200 Subject: Fix boundaries. --- challenge-067/luca-ferrari/raku/ch-1.p6 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- cgit