aboutsummaryrefslogtreecommitdiff
path: root/challenge-060/javier-luque/raku/ch-2.p6
blob: 7ef6bbc4c6551f7efba114bce8a3c6b55238b467 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Test: perl6 ch-2.p6
sub MAIN() {
    my @L = (0, 1, 2, 5);
    my $X = 2;
    my $Y = 21;
    my @answers;

    # Brute force the variations
    my @combos = @L.combinations: $X;
    for @combos -> $combo {
    	for $combo.permutations -> $perms {
    		my $n = $perms.join('').Int;
    		@answers.push($n)
    			if ($n < $Y && $n.chars == $X);
    	}
    }

    say @answers.sort.join(', ');
}