in reply to How many ways to make change?

Thare are some other neat solutions to this problem at How to generate restricted partitions of an integer.

Of course, if you'll indulge me to demonstrate a silly way to do it, I'd use regexes on unary strings as I did in my other change-making posts {1, 2}:

my $amount = shift; my $regex = join "", map { "(1{$_})*" } @ARGV; my $incr_x = qr/(?{$x++})/; local $x; (1 x $amount) =~ /^$regex(?:$)$incr_x(?!)/; print "$x\n";

blokhead