aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Lynn <bizlsg@localhost.localdomain>2023-06-06 16:43:52 +0800
committerStephen Lynn <bizlsg@localhost.localdomain>2023-06-06 16:43:52 +0800
commitbbd71ad749ca5dd0e81a0a5e0a156017b2083338 (patch)
tree1506ca88b9180b25b8e06f8ed1b59d6c1b395305
parenta23e55532b71e04ec91b07038aa92164a99c65d1 (diff)
downloadperlweeklychallenge-club-bbd71ad749ca5dd0e81a0a5e0a156017b2083338.tar.gz
perlweeklychallenge-club-bbd71ad749ca5dd0e81a0a5e0a156017b2083338.tar.bz2
perlweeklychallenge-club-bbd71ad749ca5dd0e81a0a5e0a156017b2083338.zip
ch-2.p6 fix
-rwxr-xr-xchallenge-220/steve-g-lynn/raku/ch-2.p64
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)