Thursday

Puzzles For Week 1

Here are few puzzles that will help you to prepare for Interviews.

Puzzle 1:

Puzzle asked in one of Microsoft interviews: 

Read the conditions and answer the question-

Puzzles
  • Four people have to cross an old and rickety bridge at night
  • They have only one torch and the bridge is too dangerous to cross without one 
  • The bridge is only strong enough to support two people at a time
  • Each person takes different time to cross the bridge
  • Times for different persons: 1 minute, 2 minutes, 7 minutes and 10 minutes
  • What is the shortest time needed for all four of them to cross the bridge?
Let me tell you 21 minutes is not the answer!


Puzzle 2:

Puzzle asked in one of Die Hard movies: 

You are provided with two vessels of capacity – 5 litres and 3 litres. Measure 4 litres of water in minimum steps. It is assumed that the tap is running & you can fill your vessel as many times you like.

Puzzle 3:

A farmer is going to market to sell - 
  • Stack of hay (dried grass) 
  • A Hen 
  • Wild Hound 
To reach market, he has to cross a bridge. He can take only one thing at a time. If he leaves hen with hound, the hound will eat it & similarly, hen will eat hay. Hound can’t eat hay. How will the farmer cross bridge with minimum effort?


Solution 1:

This problem involves optimization & people solving it can write codes which are efficient, optimized and fast.
  • Let's start by assuming that the people are arranged this way (Arrangement:  —— 1, 2, 7, 10)
  • Persons taking 1 minute & 2 minutes will cross = 2 minutes (Arrangement: 1,2——7,10)
  • Person taking time of 2 minutes will come back with torch = 2 minutes (Arrangement: 1——2,10,7)
  • Persons taking time of 7 & 10 minutes will cross = 10 minutes (Arrangement: 1,7,10—–2)
  • Person of 1 minute will come back = 1 minute (Arrangement: 7,10——1,2)
  • Now both taking 1 & 2 mins respectively will come back = 2 minutes (Arrangement: 1,2,7,10——-) 
  • Total time = 2 + 2 + 10 + 1 + 2 = 17 minutes

Solution 2:

The end goal of this problem is to end up with 4 litre in the 5 litre vessel, since having 4 litres in the 3 litre jug is impossible. We have a container of 3 litres - we have to find a way to measure additional 1 litre.
Here are the steps to do it:
  • Fill the 5 litre vessel and then pour it into the 3 litre vessel. The 5 litre vessel now has only 2 liters left. ( |2|3| )
  • Empty out the 3 litre vessel. Then, pour the 2 litres from the 5 litre vessel to the 3 litre vessel. So, now the 3 litre vessel has 2 litres. ( |0|2| )
  • Fill the 5 litre vessel again, and pour 1 litre into the 3 litre vessel. Now, you are left with 4 litres in the 5 litre vessel.

Solution 3:

The farmer will cross this way: 
  • Take hen with him to other side leaving hound & hay & tie it there (hen—–hound, hay) 
  • Return & take hound with him to other side (hen, hound ——hay) 
  • Take hen to other side & bring hay (hound, hay ——hen) 
  • In final round, return with hen (hound, hay, hen——)
Chance to win Gift Cards: If you have a better puzzles, send it to us.