diff options
| author | Simon Proctor <simon.proctor@zoopla.co.uk> | 2020-11-30 10:47:09 +0000 |
|---|---|---|
| committer | Simon Proctor <simon.proctor@zoopla.co.uk> | 2020-11-30 10:47:09 +0000 |
| commit | 8300307effaa6503bd3abb6988a5550f0d064057 (patch) | |
| tree | 1b9862131db856db2ee623f4d00df7c4dfc0aae1 | |
| parent | 947cf4546914ee3dbf513ea17c35dba6c1dd4dcd (diff) | |
| download | perlweeklychallenge-club-8300307effaa6503bd3abb6988a5550f0d064057.tar.gz perlweeklychallenge-club-8300307effaa6503bd3abb6988a5550f0d064057.tar.bz2 perlweeklychallenge-club-8300307effaa6503bd3abb6988a5550f0d064057.zip | |
Challenges done
| -rw-r--r-- | challenge-089/simon-proctor/raku/ch-1.raku | 8 | ||||
| -rw-r--r-- | challenge-089/simon-proctor/raku/ch-2.raku | 16 |
2 files changed, 24 insertions, 0 deletions
diff --git a/challenge-089/simon-proctor/raku/ch-1.raku b/challenge-089/simon-proctor/raku/ch-1.raku new file mode 100644 index 0000000000..3a76f49ad6 --- /dev/null +++ b/challenge-089/simon-proctor/raku/ch-1.raku @@ -0,0 +1,8 @@ +#!/usr/bin/env raku + +use v6; + +#| Given a number $N print the sum off all the GCD's of all the combinations of 1..$N +sub MAIN ( UInt $N ) { + say [+] (1..$N).combinations(2).map( -> ( $a, $b ) { $a gcd $b } ) +} diff --git a/challenge-089/simon-proctor/raku/ch-2.raku b/challenge-089/simon-proctor/raku/ch-2.raku new file mode 100644 index 0000000000..a6615fbee6 --- /dev/null +++ b/challenge-089/simon-proctor/raku/ch-2.raku @@ -0,0 +1,16 @@ +#!/usr/bin/env raku + +use v6; + +my @rows = ( (0,1,2),(3,4,5),(6,7,8), + (0,3,6),(1,4,7),(2,3,8), + (0,4,8),(2,4,6) ); + +#| Print a 3x3 grid of the number 1-9 where each horizontal, vertical and diagonal adds up to 15 +sub MAIN( Bool :a(:$all) = False ) { + for (1..9).permutations().race().grep( -> @grid { [==] ( 15, |@grid[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]].map( -> @a { [+] @a } ) ) } ) -> @grid { + say @grid.rotor(3).map( *.join( " " ) ).join("\n"); + exit unless $all; + say '---'; + } +} |
