Thursday, May 26, 2005

Camel and bananas

A camel must travel 1000 miles across a desert to the nearest city. She has 3000 bananas but can only carry 1000 at a time. For every mile she walks, she needs to eat a banana. What is the maximum number of bananas she can transport to the city?

Burning Ropes

You have 2 ropes, each of which burns for an hour (though not necessarily uniformly). How can you use these to measure out 45 minutes starting now?

Suicidal Villagers

There's a tribe living in a village in the forest and there are 100 people in it. They are very pious and religious & all want to go to heaven after they die. One day God comes to the village and says to them "there is at least one sinner among you. I will mark the sinner on the forehead. You are forbidden from looking in the mirror or any reflective surface to see if you have the mark. You are also forbidden from telling another person about a mark you see on them. You have to find out on your own if you have the mark, and commit suicide at 10am as soon as you know you have the mark. If you do so you'll go to heaven, otherwise you'll go to hell." God then marks everyone in the village (without their knowledge) and leaves. What happens next?

Witch and dwarfs

One day, a witch arrived at a dwarf village, where 10 dwarfs of different heights live. Instead of killing the dwarfs instantly, the witch decided to play a game with them. She said she would put a hat, which could be black or white, onto the head of every one of the dwarfs. Those who correctly guess the color of their own hat would be spared. What's the optimal strategy to minimize the number of dwarf deaths? Using this strategy, how many dwarfs risk death?

Cut the cake

There is a rectangular cake with a rectangular section cut out of it. The rectangular cut-out can reside anywhere in the cake in any orientation. How do you cut the cake into 2 even pieces using a single, linear cut?

Monkey on Infinite Poles

I have a tireless monkey, a row of poles, and a pot of gold. The poles are infinitely tall, spaced 3 feet apart, and are infinite in number. The monkey can climb any pole to any height you desire, but will not jump from pole to pole i.e. it has to start at the bottom of each pole to climb it and stop at the bottom of each pole to leave that pole. I have kept the pot of gold somewhere on one of these poles at some height. If the monkey comes across the pot of gold, it will stop its quest and bring you the gold. Question: What instructions will you give the monkey on how to find the gold? Answers to FAQ: Yes, the monkey has infinite energy. Yes, the poles are infinitely tall and infinite in number. No, the monkey cannot jump between poles.

Pile of Quarters

You are given 100 quarters.
You are told that 10 of them are tails and 90 are heads.
You are blindfolded.
Your job is to produce 2 piles of quarters with an equal number of tails in each.

Notes:
- The TOTAL number of quarters in each pile does not have to be the same; only the number of tails needs to be the same.
- You cannot use the trivial case of 2 piles with zero quarters each.
- You cannot see, but you can pick up, flip, throw away, stack, etc.

Truth tellers and liars

There are 3 people: one of them always tells the truth, one of them always lies, and one of them can be a truth teller or a liar. How can you tell who is who by asking them only 3 questions?

Circular String

Given two strings x, y (x.length <= y.length); Determine if x is a part of y. Catch here is that y is not a linear string, it is a circular string! Give simplest Java Program.

Prison Guard

You're in a prison with two guards & two doors. The guards decide to play a game, and offer you freedom through one door or death through the other. You are allowed exactly one question to exactly one guard. You are also told that one of the guards, you don't know which one, will answer the question truthfully & the other is guaranteed to answer with a lie, and that the only possible answers are Yes or No. You have one question. How do you get out alive?

Seat Allocation

There are 100 seats on an airplane. 100 people have tickets, each specifying a unique seat. An old lady boards the plane first, and without consideration for her ticket, sits in a random seat. Each subsequent person to board the plane attempts to sit in his prescribed seat, and if it is taken, sits in a random seat. What is the probability that the last person gets his correct seat?