You have a clock that is broken in such a way that it shows the correct time twice a day (at some unknown times). You have no way of knowing whether the clock shows AM or PM. You are allowed to set the clock correctly just once. How can you determine which is the correct time on the clock?
One way to solve this puzzle is to use a bit of logic.
Here are the steps:
- Set the clock to 12:00.
- Wait for a few minutes (let’s say, 5 minutes).
- If the clock moves forward, then you set it at 12:05 AM. If it moves backward, then you set it at 11:55 AM.
- Wait until the clock shows the same time again (let’s say, 6 hours later).
- If the clock shows 12:05, then it was set to 12:05 AM. If it shows 11:55, then it was set to 11:55 AM.
- The logic behind this solution is that if you set the clock at 12:00, then there are two possible times when the clock will show the correct time: 12:00 and some other time (let’s call it x). If you wait for a few minutes and the clock moves forward, then x must be a time between 12:00 and 12:05.
- If the clock moves backward, then x must be a time between 11:55 and 12:00. By setting the clock to either 12:05 or 11:55, you eliminate one of the possibilities, and you can use the next reading of the clock to determine whether it was set to AM or PM.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!