http://www.perlmonks.org?node_id=546499


in reply to Re^2: puzzle: how many ways to make $100
in thread puzzle: how many ways to make $100

Updates in bold below.

You have to change the original line

my @parts = (100, 50, 20, 10, 5, 1);
to match the allowed parts when comparing output. In your post (and TedPride's post) you allow $2 bills, so to get the same answer from my code you would change itthe original line above to
my @parts = (100, 50, 20, 10, 5, 2, 1);
and then the count matches. In blokhead's post, he uses coins instead of bills, so to get his answer you would change itthe original line above to
my @parts = (50, 25, 10, 5, 1);
and then the count matches.

Further update: My "original" and "change to" lines are not swapped. I'm using "original" and "change to" in reference to the code in my post above. I have added some text above to clarify which line is the "original" line and which lines are the "changed" lines.

There is a $2 bill. Just try finding one nowadays. Apparently the U.S. MintBureau of Engraving and Printing (thanks for the correction halley) is still printing them, but it must not be issuing large quantities because I almost never see one. I think it's unrealistic to expect to be able to make $100 with 50 $2 bills, for example.

Also, in the OP's $10 problem, $2 bills were not allowed:
It took them awhile, but they came up with the correct answer:
(1 ten), (2 5's), (1 5 and 5 1's), and (10 1's)