aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-11-30 21:11:10 +0000
committerGitHub <noreply@github.com>2020-11-30 21:11:10 +0000
commit2e9d00e0c08dca588ffcd531a8d688d513a05c5c (patch)
tree09fbe5fa3bf516a3cb013e0f4f7b242b01232059
parentc0a9e7951bf409c6c55b218b95014e03b550dd4d (diff)
parentdf8682ebdbb18d49486b5e8875c80657f5ccc1ba (diff)
downloadperlweeklychallenge-club-2e9d00e0c08dca588ffcd531a8d688d513a05c5c.tar.gz
perlweeklychallenge-club-2e9d00e0c08dca588ffcd531a8d688d513a05c5c.tar.bz2
perlweeklychallenge-club-2e9d00e0c08dca588ffcd531a8d688d513a05c5c.zip
Merge pull request #2886 from Scimon/master
Both the challenges done.
-rw-r--r--challenge-089/simon-proctor/raku/ch-1.raku8
-rw-r--r--challenge-089/simon-proctor/raku/ch-2.raku12
2 files changed, 20 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..c717fd08f0
--- /dev/null
+++ b/challenge-089/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,12 @@
+#!/usr/bin/env raku
+
+use v6;
+
+#| 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 '---';
+ }
+}