Three Gods - God of Truth, Lies and Chaos

Problem: You are stranded on an Island and on that island are 3 all knowing all powerful gods. One god is the god of truth, who always tells the truth and can never lie. The second god is the god of lies, he always lies and never tells the truth. The 3rd god is the god of chaos, he tells both lies and truths, however, completely randomly. The gods appear as identical twins, they all look the same. [Read More]

Labour and work problem - 20 women replaced by a men and boy alternatively

Problem: 20 women can finish a job in 20 days. After each day, one woman is replaced by a man or a boy alternatively starting with a man. Man is twice efficient and boy is half efficient as a woman. On which day does the job get completed? Solution: Lets treat man as 2 women and boy as half woman. Starting 1st day 1 W is removed and 1M added. [Read More]

How many lockers are open after 100 passes of toggles

Problem: There are one hundred closed lockers in a hallway. A man begins by opening all one hundred lockers. Next, he closes every second locker. Then he goes to every third locker and closes it if it is open or opens it if it is closed (e.g., he toggles every third locker). After his one hundredth pass in the hallway, in which he toggles only locker number one hundred, how many lockers are open? [Read More]

Two egg puzzle

Problem: There is a building of 100 floors. If an egg drops from the Nth floor or above it will break. If it’s dropped from any floor below, it will not break. You’re given 2 eggs. Find N, while minimizing the number of drops for the worst case. Solution This is similar as binary search. If we have unlimited number of eggs, we only need 7 (log 100 to base 2) to find N i. [Read More]

How long does it take to remove c ‘magical’ hats from n people

Problem: A bunch of men are on an island. A genie comes down and gathers everyone together and places a magical hat on some people’s heads (i.e., _at least one person has a ha_t). The hat is magical: it can be seen by other people, but not by the wearer of the hat himself. To remove the hat, those(and only those who have a hat) must dunk themselves underwater at exactly midnight. [Read More]

Get 4qt of water using a 5qt jug and a 3qt jug

Problem: You have a five quart jug and a three quart jug, and an unlimited supply of water (but no measuring cups). How would you come up with exactly four quarts of water? NOTE: The jugs are oddly shaped, such that filling up exactly ‘half’ of the jug would be impossible. Solution: I first thought we can come up with 2qt water by filling up the 5qt jug and pouring 3qt water to the 3qt jug. [Read More]

Covering a chess board with dominos

Problem: There is an 8×8 chess board in which two diagonally opposite corners have been cut off. You are given 31 dominos, and a single domino can cover exactly two squares. Can you use the 31 dominos to cover the entire board? Prove your answer (by providing an example, or showing why it’s impossible) Solution: No, it’s not possible. Two diagonally opposite squares on a chess board are of the same color. [Read More]

Add arithmetic operators to make 3 1 3 6 = 8 true

Problem: Add arithmetic operators (plus, minus, times, divide) to make the following expression true: 3 1 3 6 = 8. You can use any parentheses you’d like. Solution: Method 1 - Hit and try This is what I can think of :  we can first see 3+1+3+6 =13 No Multiplying is not solution either (3+1+3)/6 No 48/6 = 8 but 48 cannot be made by 3 1 3. [Read More]

Gold bar with 7 segments

Problem: You’ve got someone working for you for seven days and a 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? Solution: Break the 7 piece gold bar to make a piece of 1 segment size and the other of 2 segments size. [Read More]

Pick a Random Byte

Problem**:** You have a stream of bytes from which you can read one byte at a time. You only have enough space to store one byte. After processing those bytes, you have to return a random byte. Note: The probability of picking any one of those bytes should be equal. Solution**:**  Since we can only store one byte at a time, we have to be able to work with the bytes as they come in. [Read More]