Alice wants to buy Bob’s painting, knowing only that it costs no more than $100,000 and that the price will be an exact dollar figure (e.g. not $13.35).
Bob insists that he only accepts cash, so Alice goes out to the bank and collects $100,000. As Alice doesn’t want to risk getting mugged, she devises a plan:
She places her money in 17 sealed envelopes, numbered accordingly (i.e. they increase in value). The banknotes are distributed in such a way that no matter what price Bob asks, Alice can pay Bob exactly without having to open an envelope.
It is assumed that each envelope contains the least possible number of bills available in US currency (e.g. a fifty-dollar-bill instead of 5 ten-dollar-bills).
When Alice meets Bob, she is told that the painting costs $31721. She pays with 11 envelopes.
With how many one-dollar-bills must Alice pay?
(Remember the US Dollar Bills are $1, $2, $5, $10, $20, $50, $100)
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
If and In order to be able to pay any sum, the envelopes value should be in increasing multiple of 2, e.g. 1; 2; 4; 8... (with the exception of last envelope which is $100,000 minus the rest).
We can convert 31721 to binary and we got 111101111101001, which mean Alice use the envelope with values 1, 8, 32, 64, 128, 256, 512, 2048, 4096, 8192, 16384.
Now because we only need to count the $1 bill, and it is easy to see that if the envelope value ends with 1, 6, 8 then there is one $1 bill in that envelope, otherwise it haven't got $1 bill (ends with 3 also have $1 bill, but none of the envelope have this value).
So we got envelope 1, 8, 128, 256, 2048, 4096, which equal to six $1 bills