## Logic puzzles, math puzzles, brain teasers, and riddles

These are some of my favorites logic puzzles, math puzzles, brain teasers, and riddles. Please contact me if you have any good additions. If I like them, I'll add them to this page. I have many people to thank for giving me these riddles all of whom I cannot remember. I'm sure my father is one of them, and Iftach Nachman is another.### Other puzzle pages

In no particular order, other than alphabetical.
- A Collection of Quant Riddles With (some) Answers

- Brain Teasers

- Haidong Wang's Difficult Puzzles and Brain Teasers

- Iftach Nachman's Riddle page

- Nick's Mathematical Miscellany, most notably Nick's Mathematical Puzzles

- Paul Hsieh's puzzles

- Rustan Leino's puzzle page

- Syvum Brain Teasers and Math Puzzles

- Tanya Khovanova's favorite puzzles

- The Math Circle: Problems of the Week

- Seven Puzzles You Think You Must Not Have Heard Correctly (with solutions)

- Roger's Favorite Puzzles

### Puzzles

Find a 5 digit number, as big as possible, that when you multiply it by a single digit number, you get a six digit number, in which all digits are identical.
Create the number 24 using (all of) 1, 3, 4, and 6. You may add, subtract,
multiply, and divide. Parentheses are free. You can (and must) use each
digit only once. Note that you may not "glue" digits together. (14 - 6)
* 3 is not a solution. 1^{3} * 4 * 6 is not a solution either (powers
not allowed).

There are 100 prisoners locked up in solitary cells. There is a central living room with one light bulb; the light bulb is initially off. No prisoner can see the light bulb from his cell. Every day, the warden picks a prisoner at random (i.e., the warden may pick one prisoner multiple days in a row), and that prisoner is taken to the living room. In the room, the prisoner can do one of three things: 1) toggle the light switch, 2) do nothing, or, 3) assert that all 100 prisoners have been in the living room at least once. If this assertion is false, all 100 prisoners are shot. If it is true, they go free. Before they were locked up, they got an hour to discuss a plan. What should be their strategy? [I know of at least three solutions, only one of which will get them out within their lifetime. Try to estimate the runtime of your solution.]

A person cashes a cheque in the bank, and after he leaves the bank he buys chewing gum for 50 cents. Now, he didn't have any money when he entered the bank and when he counts the money in his pocket now he sees, to his utmost surprise, that the bank teller made a mistake: instead of the dollars he gave him the same number of cents, and instead of cents, he gave him the same number of dollars. The most bizarre situation was, that after buying the chewing gum, he now has twice the amount of money on the original cheque. What was the amount on the cheque? [Try not to write a program to solve this. There is an analytical solution.]

You and an opponent are playing a game where each person, in turn, gets to place one coin on the surface of a round table. The only rules are that the coins have to be placed flat on the table, and you are not allowed to place a coin on top of another one. The last person to successfully place a coin on the table wins. If you get to play first, what is your winning strategy?

You have 11 coins, one of which is slightly heavier or lighter. Using a balance, can you find the coin within 3 tries and say whether it's lighter or heavier? Now do the same with 12.

You have 100 bags with coins. All coins are equal, but one bag contains coins that are all 1 gram heavier than the coins in all the other bags. If you have a scale (not a balance) that you can use only once, can you find the bag with the bad coins?

You have two wicks and a box of matches. Both wicks burn for 60 minutes each, but they burn irregularly, i.e., any partial amount of wick that burned says nothing about the amount of time that passed. How do you measure 45 minutes?

A Classic: you come to a fork in the road. One road leads to Hell, the other to Heaven. On both sides of the road there is a person. One is a pathological liar (everything he says is false), the other a pathalogical truth teller (everything he says is true). If you get to ask a single question to one of them, what would you ask to choose which road you will continue your journey on?

You have a number that consists of 6 different digits. This number multiplied by 2, 3, 4, 5, and 6 yields, in all cases, a new 6-digit number, which, in all cases, is a permutation of the original 6 different digits. What's the number?

I go to a party with my wife. When we get there, four other couples arrive at the same time. We all know each other, so we all greet each other. A greeting can be a handshake, a kiss, a hug, or whatever. When everyone is done I ask everyone how many times they shook another person's hand. All answers I get are different. Given that nobody greets their own spouse, how many hands did my wife shake?

Every day, the prison warden takes out his 100 prisoners to play an evil game. He places them in a circle where everyone can see each other. He then places a hat on each prisoner's head. The hat is either red or white and he always gives the same hat to the same person. The prisoner cannot see the color of his own hat. Then, on his command, all prisoners with a white hat have to step forward. If one too few or one too many steps forward, they will all be executed. If they do it right, they all go free. If they all do nothing, they all go back to their cells and the game continues the next day. If all prisoners know there is at least one person with a white hat, how many days did it take for the prisoners to get out, and how did they do it? (Note: they are not allowed to communicate in any way about the color of their hats. For fear of execution, they don't.)

You have 55 matches arranged in some number of piles of different sizes. You now do the following operation: pick one match from each pile, and form a new pile. You repeat this ad infinitum. What is the steady state? Is it unique? [Once you solve this puzzle, you can play around with this little Ruby program to visualize the process.]

Another Classic: there are three desk lamps standing on a desk in room A. You, however, are in room B where you cannot see the lamps. There are three light switches in room B that control the three desk lamps in room A. All light switches are in the off position. You get fifteen minutes to think and act and then you will be brought to room A, where you have to state which switch corresponds to which lamp. What do you do?

You throw three darts onto the surface of a globe, each from a randomly chosen direction. What is the probability that all three darts are in one hemisphere?

How do you fill a 100-liter aquarium with 50 liters? All you get is the aquarium and a water hose.

A monk walks up a mountain to a church; it takes him a day. The next day he walks down the mountain. That also takes him a day. Prove that there's a time of day where the monk is in the exact same spot at the exact same time as the other day.

What's the next number in the following sequence?

1 11 21 1211 111221 312211

A riddle for computer scientists: if you have an array of positive numbers, zeroes, and negative numbers, how do you determine the highest sum you can make using a subarray (i.e., consecutive numbers within the array)? Can you do this in linear time?

Another riddle for computer scientists: if you have an array with random odd and even numbers, what is the most efficient algorithm you can think of to put all even numbers on one side- and all odd numbers on the other side in this array?

(Via someone that goes by Keir, whose name I forgot:) There are 100 people captured by a similarly sadistic dictator with similar rules (they can come up with a plan at the beginning, no cheating in any way, no conversation, etc.). The prisoners are lined up on a hill, single file, so that each prisoner can see everyone in front of him, and no one behind him. The dictator then places either a red or black hat on each persons head (could be 99 black, 1 red, 67 red, 33 black; they don't know). The dictator then, starting at the very last person (who can see each person in front of him, and thus can see their hats also), points a gun to the persons head. That person either yells out "Red" or "Black" for all to hear. If he guesses the colour of his hat correctly, he is set free. Otherwise, he is shot. He proceeds down the line as such. They have time to come up with a game plan before this takes place. How many people can they GUARANTEE to save, and how? (This is a legit problem... no cheating like the very back person yelling out all the people's hats, etc).