count: 344
100
50 50
50 20 20 10
50 20 20 5 5
50 20 20 5 1 1 1 1 1
50 20 20 1 1 1 1 1 1 1 1 1 1
...
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
which does not quite accord with some of the other results given.
DWIM is Perl's answer to Gödel
| [reply] [Watch: Dir/Any] [d/l] |
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)
| [reply] [Watch: Dir/Any] [d/l] [select] |
Ah, stupid USA money. Us foreign devils what don't use American money aren't aware of the quirky distribution of the denominations of notes and the OP doesn't actually mention what is available.
It is interesting to note that the addition of 2 dollar denomination increases the opportunity for making $100 by an order of magnitude.
Minor point, your "original" and "change to" lines are swapped.
Update later answers say there ought be a $2 bill. I stick by my original answer.
DWIM is Perl's answer to Gödel
| [reply] [Watch: Dir/Any] |
There is a $2 bill. Just try finding one nowadays. Apparently the U.S. Mint 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.
Just a total nit, but the US Bureau of Engraving and Printing makes the paper stuff in D.C.; the US Mint makes the coins in Denver and Philadelphia.
If you visit the USBEP, or their website, you can order as many $2 bills as you like, even in odd collectables such as uncut sheets of multiple consecutively-numbered bills.
-- [ e d @ h a l l e y . c c ]
| [reply] [Watch: Dir/Any] |
The two dollar bill is available from banks, like the $1 gold-colored coins. You find $2 bills at racetracks, mostly. People tend to avoid them, because they're so easy to mistake for $1 bills.
Since the original problem omitted $2 bills, there doesn't seem any compelling reason to include them. But I submit that it's no less reasonable to make change with 50 $2 bills, as it is to do it with 100 $1 bills.
| [reply] [Watch: Dir/Any] |