Sunday, July 31, 2011

Solution for gold for 7 days puzzle

Question: http://good-interview-puzzles.blogspot.com/2011/07/microsoft-puzzle-gold-for-7-days-of.html


The trick is not to try and how to cut in such a way to make 7 equal pieces but rather to make transactions with the worker. Make two cuts on the gold bar such that you have the following sizes of bars.


1/7, 2/7 and 4/7. For convenience sake, I would just refer to the bars as 1, 2 and 4.

At the end of Day 1: Give Bar 1 (You- 2 and 4, Worker- 1)

At the end of Day 2: Give Bar 2, Take back Bar 1 (You- 1 and 4, Worker- 2)

At the end of Day 3: Give Bar 1 (You- 4, Worker- 1 and 2)

At the end of Day 4: Give Bar 4, Take back Bar 1 and Bar 2 (You- 1 and 2, Worker- 4)

At the end of Day 5: Give Bar 1 (You- 2, Worker- 1 and 4)

At the end of Day 6: Give Bar 2, Take back Bar 1 (You- 1, Worker- 2 and 4)

At the end of Day 7: Give Bar 1 (You- Empty, Worker- 1, 2 and 4)

That should take care of everything.


No comments:

Post a Comment