aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author冯昶 <seaker@qq.com>2021-04-23 12:35:19 +0800
committer冯昶 <seaker@qq.com>2021-04-23 12:35:19 +0800
commitaf66a71f6313aa7102dff899c27ea0958e0b83d2 (patch)
tree1128721e91908ff1912e427b53201b9e9839e4a6
parent9f5a7a1af0399189b53be44ee94d534606cb8bdd (diff)
downloadperlweeklychallenge-club-af66a71f6313aa7102dff899c27ea0958e0b83d2.tar.gz
perlweeklychallenge-club-af66a71f6313aa7102dff899c27ea0958e0b83d2.tar.bz2
perlweeklychallenge-club-af66a71f6313aa7102dff899c27ea0958e0b83d2.zip
challenge 109, raku solutions
-rwxr-xr-xchallenge-109/feng-chang/raku/ch-1.raku2
-rwxr-xr-xchallenge-109/feng-chang/raku/ch-2.raku18
2 files changed, 20 insertions, 0 deletions
diff --git a/challenge-109/feng-chang/raku/ch-1.raku b/challenge-109/feng-chang/raku/ch-1.raku
new file mode 100755
index 0000000000..0e3494f184
--- /dev/null
+++ b/challenge-109/feng-chang/raku/ch-1.raku
@@ -0,0 +1,2 @@
+#!/bin/env raku
+(1..20).map({ (2..^$^a).grep($^a%%*).sum }).put;
diff --git a/challenge-109/feng-chang/raku/ch-2.raku b/challenge-109/feng-chang/raku/ch-2.raku
new file mode 100755
index 0000000000..54d6c89ced
--- /dev/null
+++ b/challenge-109/feng-chang/raku/ch-2.raku
@@ -0,0 +1,18 @@
+#!/bin/env raku
+
+sub tell-the-answer(@*a) {
+ my %h;
+ for 'a'..'g' Z ^7 -> ($c, $n) {
+ %h{$c} = @*a[$n];
+ put "$c = { %h{$c} }";
+ }
+
+ put "Box 1: a + b = {%h<a>} + {%h<b>} = { %h<a> + %h<b> }";
+ put "Box 2: b + c + d = {%h<b>} + {%h<c>} + {%h<d>} = { %h<b> + %h<c> + %h<d> }";
+ put "Box 3: d + e + f = {%h<d>} + {%h<e>} + {%h<f>} = { %h<d> + %h<e> + %h<f> }";
+ put "Box 4: f + g = {%h<f>} + {%h<g>} = { %h<f> + %h<g> }";
+
+ put ' - ' x 11;
+}
+
+(1..7).permutations.grep({ .&tell-the-answer if .[0]+.[1] == .[1]+.[2]+.[3] == .[3]+.[4]+.[5] == .[5]+.[6] });