diff options
| author | Stephen Lynn <bizlsg@localhost.localdomain> | 2023-06-06 16:43:52 +0800 |
|---|---|---|
| committer | Stephen Lynn <bizlsg@localhost.localdomain> | 2023-06-06 16:43:52 +0800 |
| commit | bbd71ad749ca5dd0e81a0a5e0a156017b2083338 (patch) | |
| tree | 1506ca88b9180b25b8e06f8ed1b59d6c1b395305 | |
| parent | a23e55532b71e04ec91b07038aa92164a99c65d1 (diff) | |
| download | perlweeklychallenge-club-bbd71ad749ca5dd0e81a0a5e0a156017b2083338.tar.gz perlweeklychallenge-club-bbd71ad749ca5dd0e81a0a5e0a156017b2083338.tar.bz2 perlweeklychallenge-club-bbd71ad749ca5dd0e81a0a5e0a156017b2083338.zip | |
ch-2.p6 fix
| -rwxr-xr-x | challenge-220/steve-g-lynn/raku/ch-2.p6 | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/challenge-220/steve-g-lynn/raku/ch-2.p6 b/challenge-220/steve-g-lynn/raku/ch-2.p6 index 712e9eb8e8..edeea0a7ac 100755 --- a/challenge-220/steve-g-lynn/raku/ch-2.p6 +++ b/challenge-220/steve-g-lynn/raku/ch-2.p6 @@ -9,9 +9,9 @@ multi sub is_perfect_square( @ints ) { } sub squareful (@ints where @ints.elems==3) { - @ints.permutations.grep( {$_.&is_perfect_square} ) + @ints.permutations.grep( {$_.&is_perfect_square} ).unique( :with(&[eqv]) ); } say &squareful((1,17,8)); #(1,8,17),(17,8,1) -say &squareful((2,2,2)); #((2 2 2) (2 2 2) (2 2 2) (2 2 2) (2 2 2) (2 2 2)) .permutations treats each element of @ints as unique, so all 6 permutations are returned. +say &squareful((2,2,2)); #((2 2 2) |
