Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple - Hourglass

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have three hour glasses 9, 11 and 14 minutes. You need to measure 7 minutes. How do you get 7 minutes in the shortest elapsed time and the longest elapsed time?

Eric
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Easy first answer, not sure if it's the shortest:
Fire up the 9 and the 11. When the 9 finishes, restart it. When the 11 finishes, fire up the 14. When the second 9 finishes, you have 7 minutes before the 14 ends.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's possible to measure 7 minutes in 16 minutes elapsed time, starting with all hourglasses drained. I think that's the shortest possible.

I don't think there is any "longest elapsed time" - you can extend the process indefinitely.

Nick, in your solution you don't need the 14 at all. There were 7 minutes between the end of the 11 and the end of the second 9. 18 minutes elapsed. (Rather than 25 using the 14.)
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'll be damned. It would seem that 11-9=2, not 3.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I messed up the question, I typed one while preparing another one.

The question should read:

You have three hour glasses 9, 11 and 14 minutes. You need to measure 7 minutes. How do you get 7 minutes in the shortest elapsed time using all three and the shortest elapsed time using only 2 of the three timers. Your choice with two of them.

Sorry about that....

Eric
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have three hour glasses 9, 11 and 14 minutes. You need to measure 7 minutes. How do you get 7 minutes in the shortest elapsed time using all three and the shortest elapsed time using only 2 of the three timers. Your choice with two of them.

Are we allowed to stop an hourglass halfway? If allowed, I think the shortest elapsed time using all three hourglasses is 16.

The shortest elapsed time for two hourglasses is 18. I chose 9 and 11. Start both hourglasses. Restart the 9 mins hour glass when it ends. When the 11 mins hourglass ends, the 9 mins hour glass left 7 minutes.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would you know that it was exactly halfway?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Joyce means, are we allowed to set an hourglass on its side while it's running, thereby stopping it (presumably to be restarted later). That's what I did to get 16 too. I also agree that 18 minutes using the 9 and 11 seems to be the best possible solution for two hourglasses. Note that this solution was also present in Nick's earlier answer.
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Pascarello:
How would you know that it was exactly halfway?


Okay, not halfway. Start three hourglasses. When the 9 mins hourglass ends, stops the 14 mins hourglass (left 5 mins). The 11 mins hourglass left two minutes and when this ends, the 14 mins hourglass can be continued for the next 5 mins.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic