aboutsummaryrefslogtreecommitdiff
path: root/challenge-075/ash/raku/ch-1.raku
blob: 681643dc6ac3be4149760b03c61a4ed5fc472f84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env raku

# Task 1 from
# https://perlweeklychallenge.org/blog/perl-weekly-challenge-075/

# Comments: https://andrewshitov.com/2020/08/29/the-raku-challenge-week-75/

my @coins = 1, 2, 4;
my $sum = 6;

my @wallet;
@wallet.append: $_ xx ($sum div $_) for @coins;

# say @wallet;

.say for @wallet.combinations.unique(:as(*.Str)).grep({$sum == [+] $_});

# Output:
#
# $ raku ch-1.raku 
# (2 4)
# (1 1 4)
# (2 2 2)
# (1 1 2 2)
# (1 1 1 1 2)
# (1 1 1 1 1 1)