Tutorials, Free Online Tutorials,It Challengers provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, core java, sql, php, c language etc. for beginners and professionals.

Breaking

Showing posts with label Interview Puzzle. Show all posts
Showing posts with label Interview Puzzle. Show all posts
10:59 am

What is number of birds on tree A and B

Interview Puzzle

(Q.) There are two trees A and B. Both the trees have few birds. Birds on tree A said to birds on B: -
             "If one of you come to us, we will be equal in number" 
Birds on tree B said to birds on A: -
             "If one of you come to us, we will be double to you" 
What is number of birds on tree A and B?

------------------------------------------------------------------------------------
Answer:- 5 Birds on A & 7 Birds on B
------------------------------------------------------------------------------------
10:45 am

Three Students and One Teacher Puzzle

Interview Puzzle

There are three students and one teacher the teacher ask a question and student give answer for that question if answer is correct then only he allow to enter in class.
-----------------------------------------------------------------------------------------------------------
Teacher:12 ?
1st student: 6
Teacher:come in

Teacher:6 ?
2nd student: 3
Teacher:come in

Teacher:10 ?
3rd student: 5
Teacher:wrong, don't come!!!!!!!!!!
what should be the answer of 3rd student to enter in class?
--------------------------------------------------------------------------------------------------------------
Answer:-   3

 12: twelve = 6(letters) ,
  6:six= 3 (letters) so, 
 10:ten= 3
---------------------------------------------------------------------------------------------------------------
1:47 am

2 Eggs and 100 Floors Puzzle

(Q). You have two identical eggs. Standing in front of a 100 floor building, you wonder what is the maximum number of floors from which the egg can be dropped without breaking it. What is the minimum number of tries needed to find out the solution?
----------------------------------------------------------------------------------------------------------------
Answer:-




Instead of taking equal intervals, we can increase the number of floors by one less than the previous increment. 
For example, let’s first try at floor 14. If it breaks, then we need 13 more tries to find the solution. If it doesn’t break, then we should try floor 27 (14 + 13).

If it breaks, we need 12 more tries to find the solution. So the initial 2 tries plus the additional 12 tries would still be 14 tries in total.

If it doesn’t break, we can try 39 (27 + 12) and so on. Using 14 as the initial floor, we can reach up to floor 105 (14 + 13 + 12 + … + 1) before we need more than 14 tries. Since we only need to cover 100 floors, 14 tries is sufficient to find the solution.
Therefore, 14 is the least number of tries to find out the solution.

2nd Method:-
-----------------------------------------------------------------------------------------
Let x be the answer we want, the number of drops required.

So if the first egg breaks maximum we can have x-1 drops and so we must always put the first egg from height x. So we have determined that for a given x we must drop the first ball from x height. And now if the first drop of the first egg doesn’t breaks we can have x-2 drops for the second egg if the first egg breaks in the second drop.

Taking an example, lets say 16 is my answer. That I need 16 drops to find out the answer. Lets see whether we can find out the height in 16 drops. First we drop from height 16,and if it breaks we try all floors from 1 to 15.If the egg don’t break then we have left 15 drops, so we will drop it from 16+15+1 =32nd floor. The reason being if it breaks at 32nd floor we can try all the floors from 17 to 31 in 14 drops (total of 16 drops). Now if it did not break then we have left 13 drops. and we can figure out whether we can find out whether we can figure out the floor in 16 drops.

Lets take the case with 16 as the answer

1 + 15 16 if breaks at 16 checks from 1 to 15 in 15 drops
1 + 14 31 if breaks at 31 checks from 17 to 30 in 14 drops
1 + 13 45 .....
1 + 12 58
1 + 11 70
1 + 10 81
1 + 9 91
1 + 8 100 We can easily do in the end as we have enough drops to accomplish the task


Now finding out the optimal one we can see that we could have done it in either 15 or 14 drops only but how can we find the optimal one. From the above table we can see that the optimal one will be needing 0 linear trials in the last step.

So we could write it as

(1+p) + (1+(p-1))+ (1+(p-2)) + .........+ (1+0) >= 100.

Let 1+p=q which is the answer we are looking for

q (q+1)/2 >=100

Solving for 100 you get q=14.
So the answer is: 14
Drop first orb from floors 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100... (i.e. move up 14 then 13, then 12 floors, etc) until it breaks (or doesn't at 100)
10:18 am

3 switches, one lightbulb

Q.> You have a set of 3 light switches outside a closed door. One of them controls the light inside the room. With the door closed from outside the room, you can turn the light switches on or off as many times as you would like.

You can go into the room - one time only - to see the light. You cannot see the whether the light is on or off from outside the room, nor can you change the light switches while inside the room.

No one else is in the room to help you. The room has no windows.

Based on the information above, how would you determine which of the three light switches controls the light inside the room?







Answer:-


  • You could turn on the first one for two minutes and turn it off. Then the middle for two minutes and turn it off. Then the last and run inside. If it is on then it is the last is it. If the bulb feels hot then the middle one. If only warm then the first.

  • first any one of the switch and let it be on for 10 min and then close on the another switch and go inside the room if the bulb is lighted then the correct switch is 2 and if the bulb if not lighted but it is hot (feel it by touching) then it is the 1st switch otherwise the 3 rd switch

12:53 pm

Burning ropes puzzle

You have two ropes. Each takes exactly 60 minutes to burn. They are made of different material so even though they take the same amount of time to burn, they burn at separate rates. In addition, each rope burns inconsistently. How do you measure out exactly 45 minutes?




Answer:
 
1.) Take one rope and burn it at both ends. This will now take 30 minutes to burn.

At the same time, burn one end of the other rope.

After 30 minutes, the first rope has completed burning and the second rope has 30 minutes of burning left.

Now light the other end of the remaining rope, which will instead take 15 minutes to burn.

When it completes burning, that will be 45 minutes.




2.) We have two ropes A and B. Light A from both the ends and B from one end. When A is finished burning we know that 30 minutes have elapsed and B has 30 minutes remaining. Now, light the other end of B also so that remaining part of B will burn at double speed taking 15 minutes to burn. Thus, we have got 30+15 = 45 minutes.
12:34 am

Guess What I am? Puzzle

Guess What I am?

I am a Five letters Word.
People eat me.
If you remove first letter, I will be a form of energy.
If you remove my first two letters, I will be needed for living.
If you remove my first three letters, I will be near you.
If you remove my first four letters, I will be drink for you.
Guess What I Am
Answer:--Wheat

10:13 pm

Crossing the Bridge Puzzle

 Four people need to cross a rickety bridge at night. Unfortunately, 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. Not all people take the same time to cross the bridge. Times for each person: 1 min, 2 mins, 7 mins and 10 mins. What is the shortest time needed for all four of them to cross the bridge?
Solution:     Total 17 min.
crossing the bridge puzzle
crossing the bridge puzzle
1 and 2 go first, then 1 comes back. Then 7 and 10 go and 2 comes back. Then 1 and 2 go again, it makes a total of 17 minutes.
1 & 2 Crosses Time –> 2Min
1 return Time –> 1Min
3 & 4 Crosses Time –> 10Min
2 return Time –> 2Min
1 & 2 Cross Time –> 2Min
Total Time –> 17Min



Pervious                                                                   Next Page

6:34 am

3 Ants and Triangle- Interview Puzzle

1.Three ants are sitting at the three corners of an equilateral triangle. Each ant starts randomly picks a direction and starts to move along the edge of the triangle. What is the probability that none of the ants collide?


Solution:-

So let’s think this through. The ants can only avoid a collision if they all decide to move in the same direction (either clockwise or anti-clockwise). If the ants do not pick the same direction, there will definitely be a collision. Each ant has the option to either move clockwise or anti-clockwise. There is a one in two chance that an ant decides to pick a particular direction. Using simple probability calculations, we can determine the probability of no collision.

P(No collision) = P(All ants go in a clockwise direction) + P( All ants go in an anti-clockwise direction) = 0.5 * 0.5 * 0.5 + 0.5 * 0.5 * 0.5 = 0.25


A simple way to solve.


  1. Each ant has 2 possibilities of moving in a direction.. clockwise or anti-clockwise. Now as there are 3 ants .. we have 8 total possibilities of the ants moving in a direction.

Now out of 8 we can have only 2 possibilities where they will not collide.
i.e if all the ants travel clockwise or all the ants travel anti-clockwise.
so the probability is 2/8 = 1/4 = 0.25

  • P(#collision)=  #of way when there is no collision/ total number of way ants can move

= 2/2^3
= 1/4