aboutsummaryrefslogtreecommitdiff
path: root/challenge-051/simon-proctor/raku/ch-1.p6
blob: d60f9d709e8f1b170ac19c06617bbac932f4983e (plain)
1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/env perl6

use v6;

#| Given a target number and a list of integers, print out all the triplets of numbers that add up to the target
sub MAIN (
    Int $target, #= Target number
    *@values where { @values.elems >= 3 && @values.all ~~ Int } #= 3 or more integers numbers to check
) {
    .say for @values.combinations(3).grep( { ([+] $_) == $target } ).map( *.join(",") );
}