-4

How to distribute 1000$ in ten boxes so that any amount of money between $1 and $1000(both inclusive) can be given as some combinations of these boxes.

Please provide any hints on how to approach this.I tried but couldn't make any solution.

user122345656
  • 1,523
  • 5
  • 15
  • 20

2 Answers2

3

have you ever did binary to decimal conversion ? Take any number between 1 and 1000 and try converting it into binary. You'll figure out that you are dealing in powers of 2.

Distribute in powers of 2 and then for whatever amount you need, just convert it into binary and pick those boxes for which bit is set to 1.

roger_that
  • 9,493
  • 18
  • 66
  • 102
  • What do you mean by "you are dealing in powers of 2"?Could you elaborate a bit? – Aravind Jul 05 '13 at 05:34
  • How do you convert a decimal into binary? You have a kind of GP series with common ratio = 2. Like if you need to convert 15(let say the amount) then you will have : **.....,16, 8, 4, 2, 1 ** something of this sort and for 15, you need last four numbers (8+4+2+1) means these bits are set to 1 gives you 1111 as 15. Now, in terms of puzzle, put the amount in boxes in forms of powers of 2 and then for 15, convert it to binary, find the set bit, and pick boxes for those numbers. – roger_that Jul 05 '13 at 06:11
  • Thanx for your ans i got the logic. – user122345656 Jul 05 '13 at 06:15
  • @VaibhavShukla: Thanks, I din't understand the question, once the question was clear, everything fell in place! – Aravind Jul 05 '13 at 06:20
2

Write all the numbers from 1 to 1000 in base-two representation. These numbers require ten bits since 2^10 = 1024. Your boxes are powers of two up to 2^8, and 489 for the last box (2^0 to 2^8 and 489 gives you ten boxes and 2^0 + 2^1 + ... + 2^8 + 489 = 2^9 - 1 + 489 = 511 + 489 = 1000), and the bit representations give you proof that you can write any number of to 1000 as a combination of these boxes (clearly anything up to 511 is okay, for anything greater than 511, subtract 489 and then note that you can write the remainder as a combination of the other 8 boxes since it is guaranteed to be less than or equal to 511).

jason
  • 236,483
  • 35
  • 423
  • 525