aboutsummaryrefslogtreecommitdiff
path: root/challenge-030
diff options
context:
space:
mode:
authorthreadless-screw <threadless-screw@mailbox.org>2019-10-21 00:00:01 +0200
committerthreadless-screw <threadless-screw@mailbox.org>2019-10-21 00:00:01 +0200
commite6abf6e96ba641863e188a9873362ce66bdd7d64 (patch)
tree0d9716133b6ca8dd68356a467ab3f563f8d4343e /challenge-030
parent932bac97c6fc2ed1d6162ac838a7c2ffeb52d4c5 (diff)
downloadperlweeklychallenge-club-e6abf6e96ba641863e188a9873362ce66bdd7d64.tar.gz
perlweeklychallenge-club-e6abf6e96ba641863e188a9873362ce66bdd7d64.tar.bz2
perlweeklychallenge-club-e6abf6e96ba641863e188a9873362ce66bdd7d64.zip
ozzy-wk30-ch2p6
Diffstat (limited to 'challenge-030')
-rw-r--r--challenge-030/ozzy/perl6/ch-2.p68
1 files changed, 8 insertions, 0 deletions
diff --git a/challenge-030/ozzy/perl6/ch-2.p6 b/challenge-030/ozzy/perl6/ch-2.p6
new file mode 100644
index 0000000000..d7ccfc6205
--- /dev/null
+++ b/challenge-030/ozzy/perl6/ch-2.p6
@@ -0,0 +1,8 @@
+#!/bin/env perl6
+
+# Challenge: Write a script to print all possible series of 3 positive numbers, where in each series
+# at least one of the number is even and sum of the three numbers is always 12. For example, 3,4,5.
+# NOTE: For the purpose of this solution, 0 is considered a positive, even number.
+
+say "Combinations: ", my @c = (^9).combinations(3).grep: { .sum == 12 && (.first: * %% 2).defined };
+say "Permutations: ", my @p = gather { my @x; for @c -> $l { @x = $l.permutations; .take for @x } };