The Jeweler and the Five Rings
A king asks a learned man to visit his palace, to which the learned man responds:
"I will come some day next month, but I will not tell you on which day. Further, you must give me gold in grams equal to the date on which I come."
In preparation for the visit, the king demands that his jeweler make gold rings of 1 to 31 grams.
The wise jeweler made only 5 rings. What are their weights?
the weights of 5 rings are:
1, 2, 4, 8, 16 grams
Using these combination of 5 type of weights you can reward 1-31 grams in weight to the wise man.
If wise man visit on 3rd day, you can give him ring with 1 & 2 grams.
If wise man visit on 15th day, you can give him ring with 1, 2, 4, 8 grams.
If wise man visit on 30th day, you can give him ring with 2, 4, 8, 16 grams.
You can do this for all possible number of days.
The rings are going to weigh:
1, 2, 4, 8, and 16 grams
Since each ring will or will not be used, all we have to do is represent the numbers in binary, and give the corresponding rings.
As an example, 5 is 00101 in binary, so we give the rings of weight 4 and 1, and 19 will be 01011, so 16+2+1, and 31 is 11111, so we give all of the rings.
The answer is
Since 5 rings are made..We can stop up to 5 numbers.