diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2023-06-12 03:40:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-12 03:40:45 +0100 |
| commit | 6e4826e533e536538129a4e72b9930c2c6eaaf5d (patch) | |
| tree | a84712a3f98e65c01f368a7b0fe35b1ab5a7c711 | |
| parent | 6264085abd267b003b1767cfaf9d9671ff271bc9 (diff) | |
| parent | 44e32b041c03e02f4ec0a1e119dff7840bdb2111 (diff) | |
| download | perlweeklychallenge-club-6e4826e533e536538129a4e72b9930c2c6eaaf5d.tar.gz perlweeklychallenge-club-6e4826e533e536538129a4e72b9930c2c6eaaf5d.tar.bz2 perlweeklychallenge-club-6e4826e533e536538129a4e72b9930c2c6eaaf5d.zip | |
Merge pull request #8192 from arnesom/branch-for-challenge-220
Arne Sommer
| -rw-r--r-- | challenge-220/arne-sommer/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-220/arne-sommer/raku/ch-1.raku | 9 | ||||
| -rwxr-xr-x | challenge-220/arne-sommer/raku/ch-2.raku | 21 | ||||
| -rwxr-xr-x | challenge-220/arne-sommer/raku/common-characters | 9 | ||||
| -rwxr-xr-x | challenge-220/arne-sommer/raku/squareful | 21 |
5 files changed, 61 insertions, 0 deletions
diff --git a/challenge-220/arne-sommer/blog.txt b/challenge-220/arne-sommer/blog.txt new file mode 100644 index 0000000000..b651a9bf4b --- /dev/null +++ b/challenge-220/arne-sommer/blog.txt @@ -0,0 +1 @@ +https://raku-musings.com/squarefully-common.html diff --git a/challenge-220/arne-sommer/raku/ch-1.raku b/challenge-220/arne-sommer/raku/ch-1.raku new file mode 100755 index 0000000000..cf1a0759e2 --- /dev/null +++ b/challenge-220/arne-sommer/raku/ch-1.raku @@ -0,0 +1,9 @@ +#! /usr/bin/env raku + +unit sub MAIN (*@words where @words.elems > 1 && all(@words) ~~ /^<[a..zA..Z]>+$/, :v(:$verbose)); + +my $set = [(&)] @words>>.lc>>.comb; + +say ":Set: { $set.raku }" if $verbose; + +say '(' ~ $set.keys.sort.map({ '"' ~ $_ ~ '"' }).join(", ") ~ ')'; diff --git a/challenge-220/arne-sommer/raku/ch-2.raku b/challenge-220/arne-sommer/raku/ch-2.raku new file mode 100755 index 0000000000..fad02576a5 --- /dev/null +++ b/challenge-220/arne-sommer/raku/ch-2.raku @@ -0,0 +1,21 @@ +#! /usr/bin/env raku + +unit sub MAIN (*@ints where @ints.elems > 1 && all(@ints) ~~ Int); + +my $length = @ints.elems; +my @squareful; + +PERM-LOOP: +for @ints.permutations.unique(:with(&[eqv])) -> @permutation +{ + for 0 .. $length -2 -> $index + { + my $sum = @permutation[$index] + @permutation[$index +1]; + my $root = $sum.sqrt; + next PERM-LOOP unless $root.Int == $root; + } + + push(@squareful, @permutation); +} + +say @squareful; diff --git a/challenge-220/arne-sommer/raku/common-characters b/challenge-220/arne-sommer/raku/common-characters new file mode 100755 index 0000000000..cf1a0759e2 --- /dev/null +++ b/challenge-220/arne-sommer/raku/common-characters @@ -0,0 +1,9 @@ +#! /usr/bin/env raku + +unit sub MAIN (*@words where @words.elems > 1 && all(@words) ~~ /^<[a..zA..Z]>+$/, :v(:$verbose)); + +my $set = [(&)] @words>>.lc>>.comb; + +say ":Set: { $set.raku }" if $verbose; + +say '(' ~ $set.keys.sort.map({ '"' ~ $_ ~ '"' }).join(", ") ~ ')'; diff --git a/challenge-220/arne-sommer/raku/squareful b/challenge-220/arne-sommer/raku/squareful new file mode 100755 index 0000000000..fad02576a5 --- /dev/null +++ b/challenge-220/arne-sommer/raku/squareful @@ -0,0 +1,21 @@ +#! /usr/bin/env raku + +unit sub MAIN (*@ints where @ints.elems > 1 && all(@ints) ~~ Int); + +my $length = @ints.elems; +my @squareful; + +PERM-LOOP: +for @ints.permutations.unique(:with(&[eqv])) -> @permutation +{ + for 0 .. $length -2 -> $index + { + my $sum = @permutation[$index] + @permutation[$index +1]; + my $root = $sum.sqrt; + next PERM-LOOP unless $root.Int == $root; + } + + push(@squareful, @permutation); +} + +say @squareful; |
