Dont get screwed!!!

PROBLEM-1
A helicopter drops two trains, each on a parachute, onto a straight infinite railway line. There is an undefined distance between the two trains. Each faces the same direction, and upon landing, the parachute attached to each train falls to the ground next to the train and detaches. Each train has a microchip that controls its motion. The chips are identical. There is no way for the trains to know where they are. You need to write the code in the chip to make the trains bump into each other. Each line of code takes a single clock cycle to execute.

You can use the following commands (and only these);
MF - moves the train forward
MB - moves the train backward
IF (P) - conditional that’s satisfied if the train is next to a parachute. There is no "then" to this IF statement.
GOTO

PROBLEM-2

Your stair-climbing robot has a very simple low-level API: the "step" function takes no argument and attempts to climb one step as a side effect. Unfortunately, sometimes the attempt fails and the robot clumsily falls one step instead. The "step" function detects what happens and returns a boolean flag: true on success, false on failure. Write a function "step_up" that climbs one step up (by repeating "step" attempts if necessary). Assume that the robot is not already at the top of the stairs, and neither does it ever reach the bottom of the stairs. How small can you make "step_up"? Can you avoid using variables (even immutable ones) and numbers?

PROBLEM-3

You have 5 jars of pills. Each pill weighs 10 gram, except for contaminated pills contained in one jar, where each pill weighs 9 gm.Given a scale, how could you tell which jar had the contaminated pills in just one measurement?

PROBLEM-4

Given a rectangular (cuboidal for the puritans) cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife ?

PROBLEM-5

Once upon a time there was a tyrant and clever [quite unusual] king who has 2 widow sisters. Actually, they became widowed after he killed their husbands thinking they want to take his throne. Since then, every noble man in the kingdom feared to approach them. Yet, the king wanted them to remarry again. Finally, on one day, he decided that the first man knocking his private room will marry one of them. On that same day, his minister, a wise man, entered the king's private room. Here, the king told him about his plan, but he decided to give his minister another chance. He told him to make a statement; if this statement is false he has to marry the older sister and if the statement is true he has to marry the younger sister. What is the statement that saves the minister from marriage to the king's sisters???

PROBLEM-6
If you had an infinite supply of water and a 5 quart and 3 quart pail, how would you measure exactly 4 quarts?

PROBLEM-7
Give a one-line C expression to test whether a number is a power of 2.

PROBLEM-8

There are 4 women who want to cross a bridge. They all begin on the same side. You have 17 minutes to get all of them across to the other side. It is night. There is one flashlight. A maximum of two people can cross at one time. Any party who crosses, either 1 or 2 people, must have the flashlight with them. The flashlight must be walked back and forth, it cannot be thrown, etc. Each woman walks at a different speed. A pair must walk together at the rate of the slower woman's pace. Woman 1: 1 minute to cross Woman 2: 2 minutes to across Woman 3: 5 minutes to cross Woman 4: 10 minutes to cross For example if Woman 1 and Woman 4 walk across first, 10 minutes have elapsed when they get to the other side of the bridge. If Woman 4
then returns with the flashlight, a total of 20 minutes have passed and you have failed the mission. What is the order required to get all women across in 17 minutes? Now, what's the other way?

PROBLEM-9

If you are in a boat on a lake and you throw out a suitcase, Will the level of water increase in the lake?

PROBLEM-10

Connect nine dots with four lines

o o o

o o o

o o o

PROBLEM-11

You have 2 candles. Every candle lights for 60 minutes. You have to find the way to measure 45 minutes.

PROBLEM-12

A band is going in the street with a constant speed. Someone in the last row has a dog. The dog runs ahead, reaches the front row of the band and gets back to it's owner. The dog's speed was constant
all the way and while it was running the band passed 50 feet. Find the length of the dog's path,if the distance between the front and the rear row of the band is 50 feet.

PROBLEM-13

A man is running across a bridge.When he is 3/8 of the way across, he heard a train coming behind him. If he keeps running he will reach the end of the bridge at the same time with the train. If he turns around and runs back, he will get to the beginning of the bridge at the same time as the train. The man runs at a speed of 5mph. What is the speed of the train?

PROBLEM-14

There are 100 doors in a row that are all initially closed. You make 100 passes by the doors starting with the first door every time. The 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 is the state of each door after the last pass?

PROBLEM-15
A man has two paper cubes on his desk. Every day he arranges both cubes so that the front faces show the current day of the month. What numbers are required on the faces of the cubes to allow this for all possible days in the calendar?

PROBLEM-16
You have 240 barrels of wine, one of which has been poisoned. After drinking the poisoned wine, one dies within 24 hours. You have 5 slaves whom you are willing to sacrifice in order to determine which barrel contains the poisoned wine. How do you achieve this in 48 hours?

PROBLEM-17
100 prisoners agree on a strategy before playing the following game: One at a time (in some unspecified order), each of the prisoners is taken to a courtyard where there is a line of 100 boxes. The prisoner gets to make choices to open 50 of the boxes. When a box is opened, it reveals the name of a prisoner (the prisoners have distinct names). The names written in the boxes are in 1-to-1 correspondence with the prisoners; that is, each name is found in exactly one box. If after opening 50 boxes, the prisoner has not found his own name, the game is over and all the prisoners lose. But if the prisoner does find the box that contains his name among the 50 boxes he opens, then the prisoner is taken to the other side of the courtyard where he cannot communicate with the others, the boxes are once again closed, and the next prisoner is brought out into the courtyard. If all prisoners make it to the other side of the courtyard, they win.
One possible strategy is for each prisoner to randomly select 50 boxes and open them. This gives the prisoners 1 chance out of 2100 to win--a slim chance, indeed. But the prisoners can do better, using a strategy that for a random configuration of the boxes will give them a larger chance of winning. How good a strategy can you develop?

PROBLEM-18
You have 240 barrels of wine, one of which has been poisoned. After drinking the poisoned wine, one dies within 24 hours. You have 5 slaves whom you are willing to sacrifice in order to determine which barrel contains the poisoned wine. How do you achieve this in 48 hours?

PROBLEM-19
A building has 16 rooms, arranged in a 4x4 grid. There is a door between every pair of adjacent rooms ("adjacent" meaning north, south, west, and east, but no diagonals). Only the room in the northeast corner has a door that leads out of the building.
In the initial configuration, there is one person in each room. The person in the southwest corner is a psycho killer. The psycho killer has the following traits: If he enters a room where there is another person, he immediately kills that person . But he also cannot stand the site of blood, so he will not enter any room where there is a dead person.
As it happened, from that initial configuration, the psycho killer managed to get out of the building after killing all the other 15 people. What path did he take?

PROBLEM-20
A rubber band (well, a rubber string, really) is 10 meters long. There's a worm that starts at one end and crawls toward the other end, at a speed of 1 meter per hour. After each hour that passes, the rubber string is stretched so as to become 1 meter longer than it just was. Will the worm ever reach the other end of the string?


PROBLEM-21
N prisoners get together to decide on a strategy. Then, each prisoner is taken to his own isolated cell. A prison guard goes to a cell and takes its prisoner to a room where there is a switch. The switch can either be up or down. The prisoner is allowed to inspect the state of the switch and then has the option of flicking the switch. The prisoner is then taken back to his cell. The prison guard repeats this process infinitely often, each time choosing fairly among the prisoners. That is, the prison guard will choose each prisoner infinitely often.
At any time, any prisoner can exclaim "Now, every prisoner has been in the room with the switch". If, at that time, the statement is correct, all prisoners are set free; if the statement is not correct, all prisoners are immediately executed. What strategy should the prisoners use to ensure their eventual freedom?
(Just in case there's any confusion: The initial state of the switch is unknown to the prisoners. The state of the switch is changed only by the prisoners.)
As a warm-up, you may consider the same problem but with a known initial state of the switch.



Problem -22

You are standing in a school hallway lined with 100 closed lockers. You then open all 100 lockers. After this, you then close every 2nd locker (so the 2nd, 4th, 6th…98th and 100th are all closed). Then, you go to every third locker and open it if it is closed or close it if it is open (let’s call this toggling the locker for our discussion). You proceed to toggle every nth locker on pass number n. So, for example, on pass number 16 – you will toggle every 16th locker. After your hundredth pass of the hallway, in which you toggle only locker number 100, how many lockers are now open? In a hall with x lockers, how many lockers remain open after pass number x?


Problem -23

You have someone working for you for seven days and you have one gold bar to pay them. The gold bar is segmented into seven connected pieces. You must give them a piece of gold at the end of every day. If you are only allowed to make two breaks in the gold bar, how do you pay your worker?

Problem-24

You have 5 jars of pills. Each pill weighs 10 grams, except for contaminated pills contained in one jar, where each pill weighs 9 grams. Given a scale, how could you tell which jar had the contaminated pills in just one measurement?

Problem-25

You are given two 60 minute long fuse ropes (i.e. the kind that you would find on the end of a bomb) and a lighter. The fuses do not necessarily burn at a fixed rate. For example, given an 8 foot rope, it may take 5 minutes for the first 4 feet of the fuse to burn, while the last 4 feet could take 55 minutes to burn (a much slower rate) (5+55=60 minutes). Using these two fuses and the lighter, how can you determine 45 minutes? HINT: You can use the lighter any number of times

Problem-26

One train leaves Los Angeles at 15 MPH heading for New York . Another train leaves from New York at 20mph heading for Los Angeleson the same track. If a bird, flying at 25mph, leaves from Los Angeles at the same time as the train and flies back and forth between the two trains until they collide, how far will the bird have traveled?

Problem-27

You have a birthday cake and have exactly 3 cuts to cut it into 8 equal pieces. How do you do it?


Problem-28

Let’s say that you have 25 horses, and you want to pick the fastest 3 horses out of those 25. In each race, only 5 horses can run at the same time. What is the minimum number of races required to find the 3 fastest horses without using a stopwatch?

1 comment:

SACHIN PATHADE said...

Problem 1
Problem 3
Problem 4
Problem 6
Problem 8
Problem 9
Problem 10
Problem 11
Problem 13
Problem 15