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
In reply to Re: How many ways to make change?
by blokhead
in thread How many ways to make change?
by tlm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |