# Answering Brainteaser Interview Questions

## A car travels a distance of 60 miles at an average speed of 30 miles per hour. How fast does the car need to travel on the way back (taking the same road) in order to average 40 miles per hour over the course of the entire trip?

You need to build the following equation:

The total distance that needs to be traveled both ways is 120 miles. The average speed that we need to obtain is 40 miles; therefore, the car must travel for 3 hours in order to achieve that:

frac {120~miles}{40~miles~per~hour}= 3~hours

The car has already traveled for two hours:

frac {60~miles}{30~miles~per~hour}= 2~hours

So, on the way back it needs to travel only 1 hour. The distance is 60 miles. Hence the car needs to travel at 60 miles per hour.

## You have eight balls of the same size. Seven of them weigh the same, and one of them weighs slightly more. How can you find the ball that is heavier by using a balance and only two attempts at weighing?

You can put six of the balls on the balance. If one of the sides is heavier you will know that the heavier ball is on that side. If not, the heavier ball is among the two that you did not measure and it will be really easy to determine precisely which ball is heavier with your second weighing.

After you determine which side is heavier, you will be left with 3 balls to choose from. You have another attempt at weighing left. You can put two of the balls on the balance and see if one of them is heavier. If it is, then you have found the heavier ball. If it is not, then the third ball is the one that is heavier.

## A windowless room has three light bulbs. You are outside the room with 3 switches, each of them controlling one of the light bulbs. If you were told that you can enter the room only once, how are you going to tell which switch controls which light bulb?

You have to be creative in order to solve this one. You switch on two of the light bulbs and then wait for 30 minutes. Then you switch off one of them and enter the room. You will know which switch controls the light bulb that is on. Here is the tough part. How are you going to be able to determine which switch corresponds to the other two light bulbs? You will have to touch them. Yes. That’s right. Touch them and feel, which one of them is heated. That will be the other bulb that you had turned on for 30 minutes.

You will be in serious trouble if the interviewer says that the light bulbs are LED (given that they don’t emit heat 🙂 ).

## What is the sum of the numbers from 1 to 100?

There’s a little bit of history coming with this question. The math teacher of young Karl Gauss, the famous mathematician, asked the entire class to sum the numbers from 1 to 100. He expected that the task would require at least half an hour to his students, but was shocked when Gauss gave him the exact number within mere seconds.

Anyway, here is how this question is solved.

There are precisely 50 pairs of numbers from 1 to 100, whose sum is 101.

1 + 100 = 101, 2 + 99 = 101, 3 + 98 =101, etc.

50 * 101 = 5050

This trick will work for any series of numbers provided that they are evenly spaced. You need to find the sum of the first and the last number and then multiply by the number of pairs.

## You are given two containers – one is 5 and the other one is 7 gallons. How do you use them to measure 4 gallons of water?

Fill the entire 7 gallon container with water. Then use the water in the 7 gallon container in order to fill the entire 5 gallon container. This would leave 2 gallons of water in the 7 gallon container. Dump the water in the 5 gallon container and then pour in it the 2 gallons of water that are in the 7 gallon container. Fill the entire 7 gallon container with water and then start pouring the water in the 5 gallon container. Given that it is already filled with 2 gallons of water, you will be able to pour only 3 gallons, which means that 4 gallons would remain within the 7 gallon container. This is how you are able to measure 4 gallons of water.

## You have 100 balls (50 red balls and 50 blue balls) and 2 buckets. You can choose how to divide the balls into the two buckets so as to maximize the probability of selecting a blue ball if 1 ball is chosen from 1 of the buckets at random.

Put 1 blue ball in one of the buckets and put the rest of the balls in the other bucket. This way you will have 50% chance of selecting the bucket with only 1 ball and then, even if it is not selected and you have to draw a ball from the other bucket you would have almost 50% chance of selecting a blue ball (49 blue balls versus 50 red balls). The joint probability of the two events would equal almost 75%.