0% found this document useful (0 votes)
269 views6 pages

What Are The Standard Puzzles Asked in Programming Interviews - Quora

The document lists 19 puzzles that are commonly asked during programming interviews. The puzzles cover a wide range of logic and problem solving skills, including calendar puzzles, door puzzles, jar weighing puzzles, racing puzzles, direction puzzles, cake cutting puzzles, light bulb puzzles, probability puzzles, and escape route puzzles. Many of the puzzles involve deducing information from limited clues or optimizing outcomes given certain constraints.

Uploaded by

Rahul Bhaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
269 views6 pages

What Are The Standard Puzzles Asked in Programming Interviews - Quora

The document lists 19 puzzles that are commonly asked during programming interviews. The puzzles cover a wide range of logic and problem solving skills, including calendar puzzles, door puzzles, jar weighing puzzles, racing puzzles, direction puzzles, cake cutting puzzles, light bulb puzzles, probability puzzles, and escape route puzzles. Many of the puzzles involve deducing information from limited clues or optimizing outcomes given certain constraints.

Uploaded by

Rahul Bhaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

11/8/2014

(70) What are the standard puzzles asked in programming interviews? - Quora

QUESTION TOPICS

Programming Interviews

What are the standard puzzles asked in


programming interviews?

RELATED QUESTIONS

What are some interesting puzzles


asked in computer science programming
technical interviews?

Add Question Details

Job Interviews

Follow Question 861

Computer Science

Comment Share 6

Downvote
Logic Puzzles: What are some of the
best/ most common/ toughest puzzles
asked in the interviews at IITs?

Edit Topics

Rahul Bhaya

SHARE QUESTION

Edit Bio Make Anonymous

Programming Puzzles: What are some


good websites for practicing puzzles that
are asked in interviews of companies like
Blackstone, Goldman Sach... (continue)

Add your answer, or answer later.

Twitter
Facebook

11 ANSWERS

ASK TO ANSWER

QUESTION STATS

Rahul Kumar, I am a good listener


Views
Followers

54,029
861

Latest activity: 1h ago

947 upvotes by Vinay Balani, Ramoji Lingamaneni, Pratik Agarwal, (more)

1. The Calendar Problem: A man has two cubes at his desk. Every day he
arranges both cubes so that the front faces show the current day of the month.
What numbers are on the faces of the cubes to allow this?
2. A 100 doors: Y ou have 100 doors in a row that are all initially closed. Y ou
make 100 passes by the doors starting with the first door every time. First time
through you visit every door and toggle the door (if the door is closed, you open
it, if its open, you close it). The second time you only visit every 2nd door (door
#2, #4, #6). The third time, every 3rd door (door #3, #6, #9), etc, until you
only visit the 100th door. What state are the doors in after the last pass or in
general after n pass?
3. 100 Jars: There are 100 jars containing infinite number of marbles each of
10 grams except one jar which contains all marbles of 9 grams. How would
you find out which jar it is in exactly one weighing? For the same problem
what would be your approach if more than one jars had 9 gram marbles?
4. Racing horses: There are 25 horses in a racing competition. Y ou can have
race among 5 horses in a particular race. What would be the minimum
number of races that will be required to determine the 1st, 2nd and 3rd fastest
horses?
5. Two persons: one always speaks truth other always speaks false. Y ou don't
know who is what, Y ou are new to the city, you are allowed to ask exactly one
question to find out the direction (for e.g. south or north), what question would
you ask?
6. Three persons: one always speaks the truth, second always lies and third
randomly speaks the truth or lies. Y ou are allowed to ask each entity one or
more yes-no questions. Y ou are allowed to ask three such questions. Y ou must
deduce the identities of the three entities with the answers you get. How should
you ask the three questions?
7. Cake cutting: There is a rectangular shaped cake of arbitrary size; we cut a
rectangular piece (any size or orientation) from the original cake. Question is
how would you cut the remaining cake into two equal halves in a straight cut
of a knife. And obviously you cant cut the cake by its cross section.
8. The light bulb problem: Y ou have three light bulbs in a sealed room.
Y ou know that initially, all three light bulbs are off. Outside the room there are
three switches with a one-to-one correspondence to the light bulbs. Y ou may
flip the switches however you like and you may enter the room once. How
should you flip the switches to determine which switch controls which light
bulb?
9. Y ou have a cylindrical glass with 100% full of water. Y ou have to make it
50% (half). Condition: Y ou are not supposed to use any scale or any type of
measuring instrument.
10. A problem of probability: Y ou are a prisoner sentenced to death. The
Emperor offers you a chance to live by playing a simple game. He gives you 50
black marbles, 50 white marbles and 2 empty bowls. He then says, "Divide
these 100 marbles into these 2 bowls. Y ou can divide them any way you like as

http://www.quora.com/What-are-the-standard-puzzles-asked-in-programming-interviews

Programming Interviews: What are the


best programming interview questions
you've ever asked or been asked?
Puzzles and Trick Questions: What are
some of the best logical reasoning
question or puzzles you have been asked
in an interview?
What's the hardest puzzle question

asked at PayPal?
What are some of the best sites to
prepare for puzzles asked in interviews of
some business analyst companies like
Mu Sigm... (continue)
Programming Interviews: What are the
standard yet tough to get under 10 mins
kind of interview questions asked by
major tech companies?
Programming Interviews: What types of

technical questions are asked in


developer interviews?
What are some interesting game theory
based programming questions that are
commonly asked in interviews?
More Related Questions

1/6

11/8/2014

(70) What are the standard puzzles asked in programming interviews? - Quora

long as you use all the marbles. Then I will blindfold you and shuffle the bowls.
Y ou then may choose one bowl randomly and remove ONE marble from it. If
the marble is WHITE you will live, but if the marble is BLACK... you will die."
How do you divide the marbles up so that you have the greatest probability of
choosing a WHITE marble?
11. Pirates on deck: Five pirates discover a chest full of 100 gold coins. The
pirates are ranked by their years of service, Pirate 5 having five years of service,
Pirate 4 four years, and so on down to Pirate 1 with only one year of deck
scrubbing under his belt. To divide up the loot, they agree on the following:
The most senior pirate will propose a distribution of the booty. All pirates will
then vote, including the most senior pirate, and if at least 50% of the
pirates on board accept the proposal, the gold is divided as proposed. If not, the
most senior pirate is forced to walk the plank. Then the process starts over with
the next most senior pirate until a plan is approved.
The pirates
preference is first to remain alive, and next to get as much gold as possible. The
most senior pirate thinks for a moment and then proposes a plan that
maximizes his gold, and which he knows the others will accept. How does he
divide up the coins?
What plan would the most senior pirate propose on a boat full of 15 pirates?
12. What is next number in the
series:
a> 1, 11,
21, 1211, 111221,
312211...
b>
1, 20, 33, 400, 505, 660, 777,8000, 9009...
13. Sneaking Spider: A rectangular room measures 7.5 meters in length
and 3 meters in width. The room has a height of 3 meters. A spider sits 25
centimeters down from the ceiling at the middle of one of the short walls. A
sleeping fly sits 25 centimeters up from the floor at the middle of the opposite
wall. The spider wants to walk (i.e., move along the walls, floor, and ceiling
only) to the fly to catch it. How can the spider reach the fly, walking just 10
meters? Is it even possible?
14. The Fuse Problem: I have a box of one hour fuses. If I set one end of a
fuse on fire, I know that the fuse will burn all the way to the other end in
EXACTLY one hour. However, the fuses may burn unevenly [ie - it may take
59 minutes to burn the first half of a fuse, but only 1 minute to burn the other
half]. Furthermore, all of the fuses may burn unevenly at a different rate. The
only thing we know for sure is that each one takes 1 HOUR to burn
completely. The Question: Given 2 of these fuses and a lighter, how can I time
out 45 minutes precisely?
15. Dropping eggs: There is a building of 100 floors If an egg drops from the
Nth floor or above it will break If its dropped from any floor below, it will not
break Y oure given 2 eggs Find N, while minimizing the number of drops for
the worst case.
16. MIT Mathematicians: Two MIT math grads bump into each other
while shopping. They haven't seen each other in over 20
years.
First
grad to the second: "How have you been?"
Second: "Great! I got married and I have three daughters now."
First: "Really? How old are they?"
Second: "Well, the product of their ages is 72, and the sum of their ages is the
same as the number on that building over there..."
First: "Right, ok... Oh wait... Hmm, I still don't know."
Second: "Oh sorry, the oldest one just started to play the piano."
First: "Wonderful! My oldest is the same age!"
How old was the first grads daughter?
17. Crazy guy on the plane: A line of 100 airline passengers is waiting to
board a plane. They each hold a ticket to one of the 100 seats on that flight.
(For convenience, let's say that the nth passenger in line has a ticket for the
seat number n.) Unfortunately, the first person in line is crazy, and will ignore
the seat number on their ticket, picking a random seat to occupy. All of the
other passengers are quite normal, and will go to their proper seat unless it is
already occupied. If it is occupied, they will then find a free seat to sit in, at
random. What is the probability that the last (100th) person to board the plane
will sit in their proper seat (#100)?
http://www.quora.com/What-are-the-standard-puzzles-asked-in-programming-interviews

2/6

11/8/2014

(70) What are the standard puzzles asked in programming interviews? - Quora

18. Escape from Alcatraz: A prisoner stays at the maximum security prison
on Alcatraz Island. The prison is in shape of 4X4 cells, the prisoner stays at top
right cell with all other cell having a guard, only escape from prison is from
bottom left cell (see diagram for further clarification). Here are the rules for a
successful escape from the prison.

The prisoner has to escape from the prison overnight by killing all the
guards.

He can only move vertically or horizontally, no diagonal movement is


allowed.

As soon as the prisoner enters a cell he has to kill the guard.

If he sees the dead guard again he will go mad for 24 hrs out of guilt, i.e
he can't go to same cell twice.
Provide an escape route.
19. Transporting bananas: Y ou are standing at point A with 3000 bananas
and a faithful camel. Y our destination is point B which is exactly 1000 kms
away. The objective is to transport as many bananas as possible to point B,
under the following conditions.
1. Only the camel can carry bananas.
2. The maximum load that the camel can carry at a time is 1000 bananas.
3. The camel consumes 1 banana for every km that it travels. (Irrespective of
direction of travel or load)
20. There are 10 marbles of equal weight except for one which weighs a little
more. Given a balance how many weighing are required to deduce the heavier
marble. What would be the answer for N marbles? Y our answer should
consider the worst case.
21. Imagine a disk spinning like a record player turn table. Half of the disk is
black and the other is white. Assume you have an unlimited number of color
sensors. How many sensors would you have to place around the disk to
determine the direction the disk is spinning? Where would they be placed?
22. There are 3 baskets. One of them has apples, one has oranges only and the
other has mixture of apples and oranges. The labels on their baskets always lie.
(i.e. if the label says oranges, you are sure that it doesn't have oranges only, it
could be a mixture) The task is to pick one basket and pick only one fruit from
it and then correctly label all the three baskets. How do you do it?
23. Prime pairs: Pairs of primes separated by a single number are called
prime pairs. Examples are 17 and 19, 5 and 7 etc. Prove that the number
between a prime pair is always divisible by 6 (assuming both numbers in the
pair are greater than 6). Now prove that there are no 'prime triples'.
24. Suicidal Monks: There is a group of monks in a monastery. These monks
have all taken a vow of silence. They cannot communicate with each other,
and all they do is pray in a common room during the day and sleep at night. As
well, they have no mirrors in the compound. One day, the head monk calls
them all together and says "Tonight while you sleep, I will place a black X on
some of your foreheads. When you awaken, continue your normal activities.
But once you determine that you have an X, you must wait until night, and
then kill yourself". So from then on, they pray together by day, and each night
some may commit suicide. The question: if there are N monks with Xes, how
many days does it take for the N monks to commit suicide?
25. The Monty Hall problem: Y ou are given a choice between three doors
-- 1, 2, and 3. One of them contains a trip to Hawaii, and the other 2 are
empty. Y ou pick one. Then he opens one that you didn't pick, and it's empty.
He gives you the chance to switch your choice to the other door you did not
choose. Should you change your original selection?
Updated 5 Aug.
Upvote 947

Downvote Comments 24+ Share 33

http://www.quora.com/What-are-the-standard-puzzles-asked-in-programming-interviews

3/6

11/8/2014

(70) What are the standard puzzles asked in programming interviews? - Quora

Vikas Bhandari, Hardware Engineer/ Web Developer


130 upvotes by Deepak Sunanda Prabhakar, Dinesh Ravi, Balaraj
Venkataramnappa, (more)

I have written a blog on standard puzzles asked in most of the programming


interview questions. Some of the puzzles along with solutions are available at
my blog Puzzle Arena
List of puzzles which are there in my blog with solutions are
1. Puzzle Arena: Bucket Puzzle
2. Puzzle Arena: Rope Puzzle
3. Puzzle Arena: 8 Ball Puzzle
4. 1000 Bottles Puzzle
5. Bridge Crossing Puzzle I
6. Ants on a Triangle Puzzle
7. 100 Doors Puzzle
8. Puzzle Arena: Salary Puzzle
9. Puzzle Arena: Ball Puzzle
10. 17 Horses Puzzle
11. Puzzle Arena: 12 Ball Puzzle
12. 10 jars marbles puzzle
13. Puzzle Arena: Bee Puzzle
14. 50 Red and 50 Green Balls Puzzle
15. Puzzle Arena: Door Puzzle
16. Puzzle Arena: Cube Puzzle
17. Two Cubes Puzzle
18. Fruit Jars Puzzle
19. Puzzle Arena: Pill Puzzle
20. Puzzle Arena: Race Puzzle
21. Three Colour Marbles Puzzle
22. River Crossing Puzzle
23. Sand Timers Puzzle
24. Daughters Age Puzzle
Search

25. Three Friends Puzzle

Home

Open Questions

70

Notifications

Rahul

Add Question

26. Heaven or Hell Puzzle


27. Number of Girls Puzzle
28. Puzzle Arena: 1 Rupee Puzzle
Updated 1h ago. Suggest Edits

Pratik Agarwal
8 upvotes by Srinivas Kj, Vinay Balani, Dan Kinskey, (more)

1 Classic Problem:
Y ou have a gold bar, you have given a piece of work to someone. He completes
that in a week. So you decide to give him 1/7th of the gold bar every day. Y ou
can make only 3 cuts and one cut can only cut 1/7th of the bar. How will you
ensure that you give only 1/7th of the bar each day.
Hint: (Small hint, which will make you understand the question more)
http://www.quora.com/What-are-the-standard-puzzles-asked-in-programming-interviews

4/6

11/8/2014

(70) What are the standard puzzles asked in programming interviews? - Quora

1st day the worker has 1/7th of the bar, 2nd day has 2/7th, 3rd day 3/7th of
the bar and so on.
Written 6 Sep, 2013.
Upvote

Downvote Comments 3+ Share

Sumanth S Murthy
8 upvotes by Ajay Harchandani, Vijay Mahantesh, Sunil Kumar, (more)

techinterview

has it all.

Written 23 Aug, 2013.


Upvote

Downvote Comment Share

Tarun Chabarwal
2 upvotes by Manjeet Jindal and Prasad Kanhegaonkar.

This one really tricked me:


Upvote 130

Downvote Comment Share 6

Y ou've two eggs of similar shape and size but of varying strength. Now we
have a 100 floors building to find out which is stronger. Calculate the
minimum number of throws required to find this?
Y ou can tell the difference by finding a floor where one egg will break and
other will not
Written 24 Dec, 2013.
Upvote

Downvote Comments 4+ Share

Neha Garg, CrazyforCode


5 upvotes by Chetan Palavalli, Nikhil Kulkarni, Hemant Agrawal, (more)

Top 10 Interview Puzzles Y ou will find many in top programming


interviews... Specially in Google, Samsung, Flipkart, Payu, Ebay, Guavus,
Adobe etc
Written Wed.
Upvote

Downvote Comment Share

Rahul Bhaya
Edit Bio Make Anonymous

Add your answer, or answer later.

Top Stories from Your Feed

http://www.quora.com/What-are-the-standard-puzzles-asked-in-programming-interviews

5/6

11/8/2014

(70) What are the standard puzzles asked in programming interviews? - Quora

http://www.quora.com/What-are-the-standard-puzzles-asked-in-programming-interviews

6/6

You might also like