diff options
| -rw-r--r-- | challenge-220/steve-g-lynn/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-220/steve-g-lynn/raku/ch-1.p6 | 8 | ||||
| -rwxr-xr-x | challenge-220/steve-g-lynn/raku/ch-2.p6 | 17 |
3 files changed, 26 insertions, 0 deletions
diff --git a/challenge-220/steve-g-lynn/blog.txt b/challenge-220/steve-g-lynn/blog.txt new file mode 100644 index 0000000000..2ae85994be --- /dev/null +++ b/challenge-220/steve-g-lynn/blog.txt @@ -0,0 +1 @@ +https://thiujiac.blogspot.com/2023/06/pwc-220.html diff --git a/challenge-220/steve-g-lynn/raku/ch-1.p6 b/challenge-220/steve-g-lynn/raku/ch-1.p6 new file mode 100755 index 0000000000..1229f35306 --- /dev/null +++ b/challenge-220/steve-g-lynn/raku/ch-1.p6 @@ -0,0 +1,8 @@ +#!/usr/bin/perl6 + +sub common_characters( @words ) { + [(&)] @words.map( {$_.lc.comb.Set} ) +} + +say &common_characters(('Perl','Rust','Raku')); #Set(r) +say &common_characters(('love','live','leave')); #Set(e l v) diff --git a/challenge-220/steve-g-lynn/raku/ch-2.p6 b/challenge-220/steve-g-lynn/raku/ch-2.p6 new file mode 100755 index 0000000000..460d8e1204 --- /dev/null +++ b/challenge-220/steve-g-lynn/raku/ch-2.p6 @@ -0,0 +1,17 @@ +#!/usr/bin/perl6 + +multi sub is_perfect_square( Int $a, Int $b ) { + ($a+$b).sqrt %% 1; +} + +multi sub is_perfect_square( @ints ) { + ( [&&] (0 .. @ints-2).map( {&is_perfect_square( @ints[$_], @ints[$_+1] ) } ) ); +} + +sub squareful (@ints where @ints.elems==3) { + @ints.permutations.unique( :with(&[eqv]) ).grep( {$_.&is_perfect_square} ); +} + +say &squareful((1,17,8)); #(1,8,17),(17,8,1) +say &squareful((2,2,2)); #((2 2 2) + |
