diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-04-19 17:19:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-19 17:19:41 +0100 |
| commit | 53358741bb57d3a5f7b979f55ae2a96daa18bda9 (patch) | |
| tree | f6e4168c4d92a6ed08692b80ea55f47ce18bc2e7 | |
| parent | 2fd28e78b216a15c02e486b249f1e909d895f82b (diff) | |
| parent | b58bdad47f8fcf9b193c732b1c531d7bc88c64c5 (diff) | |
| download | perlweeklychallenge-club-53358741bb57d3a5f7b979f55ae2a96daa18bda9.tar.gz perlweeklychallenge-club-53358741bb57d3a5f7b979f55ae2a96daa18bda9.tar.bz2 perlweeklychallenge-club-53358741bb57d3a5f7b979f55ae2a96daa18bda9.zip | |
Merge pull request #3920 from Scimon/master
Challenge 109
| -rw-r--r-- | challenge-109/simon-proctor/raku/ch-1.raku | 10 | ||||
| -rw-r--r-- | challenge-109/simon-proctor/raku/ch-2.raku | 16 |
2 files changed, 26 insertions, 0 deletions
diff --git a/challenge-109/simon-proctor/raku/ch-1.raku b/challenge-109/simon-proctor/raku/ch-1.raku new file mode 100644 index 0000000000..99d71ecc19 --- /dev/null +++ b/challenge-109/simon-proctor/raku/ch-1.raku @@ -0,0 +1,10 @@ +#!/usr/bin/env raku + +#| Give the Chowla number up to X (default 20) +sub MAIN ( Int \X = 20 ) { + (1..X).map( { chowla($_) } ).join(",").say; +} + +sub chowla($x) { + [+] (2..^$x).grep( $x %% * ); +} diff --git a/challenge-109/simon-proctor/raku/ch-2.raku b/challenge-109/simon-proctor/raku/ch-2.raku new file mode 100644 index 0000000000..1420f24e6d --- /dev/null +++ b/challenge-109/simon-proctor/raku/ch-2.raku @@ -0,0 +1,16 @@ +#!/usr/bin/env raku + +#| Given a list of numbers a through g find a result where a+b == b+c+d == d+e+f == f+g +sub MAIN ( *@values where @values.elems == 7 && @values.all ~~ IntStr && [!==] @values.sort) { + my @res = @values.permutations.first( -> @v { [==] (@v[0]+@v[1] , @v[1]+@v[2]+@v[3], @v[3]+@v[4]+@v[5], @v[5]+@v[6]) } ); + + if ( ! defined @res[0] ) { + say "Can't find a solution"; + } else { + say "{@res[0]} + {@res[1]} = {@res[0] + @res[1]}"; + say "{@res[1]} + {@res[2]} + {@res[3]} = {@res[1] + @res[2] + @res[3]}"; + say "{@res[3]} + {@res[4]} + {@res[5]} = {@res[3] + @res[4] + @res[5]}"; + say "{@res[5]} + {@res[6]} = {@res[5] + @res[6]}"; + } + +} |
