diff options
| author | Luca Ferrari <fluca1978@gmail.com> | 2020-06-29 13:48:10 +0200 |
|---|---|---|
| committer | Luca Ferrari <fluca1978@gmail.com> | 2020-06-29 13:48:10 +0200 |
| commit | 9c185dffa7f9568cad642076729b93d3e1011168 (patch) | |
| tree | 7a80ee1b6a184f46833eb913d734fc322f1d8b11 | |
| parent | 14e647fc20118e2813d7e3aa3b31af54677b6aa5 (diff) | |
| download | perlweeklychallenge-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.p6 | 3 |
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; |
