From e6abf6e96ba641863e188a9873362ce66bdd7d64 Mon Sep 17 00:00:00 2001 From: threadless-screw Date: Mon, 21 Oct 2019 00:00:01 +0200 Subject: ozzy-wk30-ch2p6 --- challenge-030/ozzy/perl6/ch-2.p6 | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 challenge-030/ozzy/perl6/ch-2.p6 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 } }; -- cgit