Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Problem Statement
3.
Explanation
4.
Frequently Asked Questions
4.1.
What are the advantages of solving puzzles?
4.2.
How to solve a number sequence puzzle?
4.3.
Are puzzles asked in the interview of IT companies?
4.4.
What are the benefits of puzzle-solving?
4.5.
What are some of the most common interview questions and puzzles?
5.
Conclusion
Last Updated: Mar 27, 2024

Measure Time by Hourglass

Author Divyansh Jain
0 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @
Interview Puzzles

Introduction

Puzzles are a great way to develop logical thinking and cognitive thinking ability. Numerous interviews for popular companies feature a few puzzle-based questions. In this article, we discuss the problem of Measuring TIme by Hourglass

Problem Statement

Question:

What time(in minutes) can be measured while using a 4-minute hourglass and a 7-minute hourglass, with the procedure taking no longer than the time we're trying to measure?

NOTE: This is a question with multiple options. Examine all of the options that can be measured.

Choose all the correct options from the following choices:

  1. 11 minutes
  2. 8 minutes
  3. 6 minutes
  4. 9 minutes
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Explanation

illustration image

For 11 minutes

  • To count 11 minutes is also pretty easy to execute.
  • At 0 minutes: Firstly, we will run the 7-minute hourglass.
  • At 7 minutes: Now, we will allow the 4-minute hourglass to run out, and that’s it.
     

For 8 minutes

  • To count 8 minutes using a 7-minute hourglass and a 4-minute hourglass is pretty easy. We don’t need a 7-minute hourglass for this.
  • So, we will just put the 7-minute hourglass inverted, it won’t bother us.
  • At 0 minutes: We will let the 4-minute hourglass run out completely.
  • At 4 minutes: let the 4-minute hourglass run out completely again and thus simply it will lead us to 8 minutes.
     

For 6 minutes

  • No matter how many permutations we apply, it is not possible to compute 6-minute with the given two hourglasses and conditions applied.
     

For 9 minutes

  • Here, it is pretty tricky to count 9 minutes, but it’s definitely possible. So, here we go.
  • At 0 minutes: Here, both hourglasses should be started at the same time.
  • At 4 minutes: At this moment, the 4 minutes hourglass runs out, and flip it. Now, Only 3 minutes remaining in the 7-minute hourglass.
  • At 7 minutes: There is 1 minute remaining in the 4-minute hourglass. 
  • And, the 7-minute hourglass runs empty, so we will flip it.
  • At 8 minutes: The 4-minute hourglass runs out empty and the 7-minute hourglass is loaded with 6 minutes and 1 minute on the other side. With 1 minute left in the glass, flip it.
  • At 9 minutes: And finally, the 7-minute hourglass runs empty from the above side and we calculated the 9-minute frame.

Frequently Asked Questions

What are the advantages of solving puzzles?

Solving puzzles enhances the problem-solving skills of a person. It also improves the logic building of a person.

How to solve a number sequence puzzle?

To solve a number sequence puzzle, first, find the pattern between numbers of the sequence. Once you know the pattern then you can find the next number of the sequence by following the same pattern.

Are puzzles asked in the interview of IT companies?

Many tech giants like Google, Microsoft, etc., ask the puzzles in the interview process as they want to check your logical thinking.

What are the benefits of puzzle-solving?

People's problem-solving skills improve when they solve puzzles. It also helps a person's logic.
 

What are some of the most common interview questions and puzzles?

The following are some of the most common interview puzzles:
→ The Man in the Elevator Puzzle
→ Gold Bar Cut Puzzle
→ Horses on a Race Track Puzzle
→ Tomato Soup Puzzle
→ Bag of Coins Puzzle

Conclusion

To summarize the article, we have talked about a very interesting puzzle including hourglasses calculations and permutations to reach the resulted output. Also, we have discussed some frequent doubts regarding the subject.

Recommended Readings:

 

You can also refer to our test series and problems section in code studio. And, to crack the interview, refer to the Top 150 interview puzzles.

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, Aptitude, etc. Enroll in our courses and refer to the mock test and problems available, Take a look at the interview experiences and interview bundle for placement preparations.

Do upvote our blog to help other ninjas grow.

Happy Learning Ninja :)

Previous article
Color of the Last Ball II
Next article
Make a Statement
Live masterclass