diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-10-20 23:06:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-20 23:06:35 +0100 |
| commit | 026954ce419d207e85357f97a1e8cb1b180ce4ad (patch) | |
| tree | a2ae315f67834a667ab63b225b8a26fb6009407f | |
| parent | b0d02ae8da05be4384efa2ecdd134caf8c6d856d (diff) | |
| parent | e6abf6e96ba641863e188a9873362ce66bdd7d64 (diff) | |
| download | perlweeklychallenge-club-026954ce419d207e85357f97a1e8cb1b180ce4ad.tar.gz perlweeklychallenge-club-026954ce419d207e85357f97a1e8cb1b180ce4ad.tar.bz2 perlweeklychallenge-club-026954ce419d207e85357f97a1e8cb1b180ce4ad.zip | |
Merge pull request #814 from threadless-screw/ozzy-wk30
ozzy-wk30-ch2p6
| -rw-r--r-- | challenge-030/ozzy/perl6/ch-2.p6 | 8 |
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 } }; |
