Question 596598: I need to fill unit orders between 1 and 1000 pieces of candy. I only have 10 different bag sizes. How many pieces should be in each bag to fill any quantity ordered between 1 and 1000 without using two of any size?
Answer by richard1234(7193) (Show Source):
You can put this solution on YOUR website! Use ten bags that can hold 1, 2, 4, 8, ..., 512 pieces of candy. This is because every integer has a unique binary representation (e.g. 683 = 1010101111, 512+128+32+8+4+2+1). By using ten bags, you can hold any amount up to 1023 (2^10 - 1) pieces of candy.
|
|
|