diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2023-06-12 03:48:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-12 03:48:32 +0100 |
| commit | 0c90aabb5157caf3f8a8f809bf2c74b5731ef89a (patch) | |
| tree | 83aebf037f0d4666c9bc3fde450143fdada51306 | |
| parent | 48beedcdca7ecb7448cc274053b8171b6412627d (diff) | |
| parent | bcc5ed65920a39ad387714f12fa8ede117d249ca (diff) | |
| download | perlweeklychallenge-club-0c90aabb5157caf3f8a8f809bf2c74b5731ef89a.tar.gz perlweeklychallenge-club-0c90aabb5157caf3f8a8f809bf2c74b5731ef89a.tar.bz2 perlweeklychallenge-club-0c90aabb5157caf3f8a8f809bf2c74b5731ef89a.zip | |
Merge pull request #8197 from steve-g-lynn/branch-for-challenge-220
Branch for challenge 220
| -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) + |
