Monday, August 24, 2015

Riddle me this

This will be quick and it doesn't have any code but it is an exercise in thinking through a solution to a problem.



Picture this:

You have 8 balls, say ping pong balls, they all all the same weight except one heavy one. Your challenge is to determine which one is the heavy one but you only allowed to use the scale twice.







Given 3 uses of the scale the solution would be easy but with only two chances to weigh the balls you need to get creative.  It took me a while to get it but once you do it will seem so obvious.


Hint: Not all the balls need to be weighed.




example of another riddle turned into code

2 comments:

  1. The solution I came up with is to weigh six balls (3 on each side). Then, if they are equal, weigh the remaining two and you will know which is heavier. Or, if they are not equal, then you take the side that was heavier and weigh one ball each. If they are equal, the third ball that wasn't weighed is the heavy one. If they are not equal then that is the heavy one. That seems to work.

    ReplyDelete
    Replies
    1. Very nice!! That is exactly how I solved it as well.

      Delete