Archive for the ‘Riddles’ Category

Monochrome Lizards

Tuesday, March 29th, 2011

Uniform LizardsThere are 3 types of lizards: yellow, green and blue.

If you rub 2 lizards from different colors, they both change color to the third color. So, for example, if you rub a yellow lizard and a blue lizard, you get 2 green lizards.

Say that you have X yellow lizards, Y green lizards and Z blue lizards. For what values of X, Y and Z can you transform all the lizards to the same color?

E.g. for X=3, Y=3 and Z=1 it is possible (rub the 3 yellow ones with the 3 green ones and get a total of 7 blue ones).

Zeroing an Array in Constant Time

Thursday, January 20th, 2011

This one is a really cool (and practical) riddle!

Implement an “integer array” data structure, that supports the following 3 operations:

Init(int n, int k) – initialize the array to be of size n and with all cells set to the value k.

Get(int i) – return the value at cell i.

Set(int i, int k) – set the value of cell i to k.

The catch – all 3 operations should take constant time (not amortized, not probabilistic).

Note – you can assume that malloc or new are constant time, but that the returned memory is filled with (adversarial) random.

Thanks to Nadav Sherman for this riddle!

Differing Neighbors

Wednesday, January 12th, 2011

Algorithm A

Given an array of N integers, sort the array, and find the 2 consecutive numbers in the sorted array with the maximum difference.
Example – on input [1,7,3,2] output 4 (the sorted array is [1,2,3,7], and the maximum difference is 7-3=4).

Algorithm A runs in O(NlogN) time.

Implement an algorithm identical in function to algorithm A, that runs in O(N) time.

Thanks to Yossi Richter for this riddle!

Prisoners with Bit Sequences

Friday, May 28th, 2010

This is a hard riddle – it took me a couple of days (wall-time) to solve, but it was definitely worth it. Be warned – a certain mathematical maturity is needed…

There are three prisoners and a guard. The guard has an infinite sequence that is either all 1′s (e.g. 1111111111…) or it starts with a finite number of 1′s and eventually turns into 2′s (e.g. 1112222222…). The guard creates 3 bit sequences (i.e. composed entirely of 0′s and 1′s) such that the sum of the i’th bit in the 3 sequences is equal to the i’th element in his sequence (1 or 2).

He then gives each of the 3 prisoners one of the 3 bit sequences. Each prisoner sees only his own sequence and has to guess whether the guard’s sequence consists only of 1′s or whether it turns into 2′s eventually. Devise a method that will make sure the majority of the prisoners (i.e. at least 2) guess correctly.

Thanks Haran for giving me this cool riddle!

The Better Half

Wednesday, May 19th, 2010

A cute and easy algorithmic riddle.

You have an array of N bit strings each of length M. You know that there is at least one element that appears more than N/8 times in the array. Using O(M+log(N)) memory and O(NM) time, find such an element.

An Easier Version

Well, its actually almost exactly the same, but solve the above riddle in case there is an element that appears more than N/2 times in the array. I managed to find 3 distinct solutions to this easier variation, but only one of which generalizes easily.

Thanks Nemo for giving me this riddle!

Reverse & Clean

Saturday, April 17th, 2010

The game of Reverse & Clean is a one player game, played on an N by M board, filled with Reversi pieces. Each Reversi piece has a black side and a white side. The game starts with all pieces showing their white side, except for the piece in the lower right corner, which shows its black side. See the figure for a 3 by 3 example.

reversi1.png

In each turn of the game, you remove one of the black pieces and flip all of its (remaining) neighbours (the pieces up, down, left and right of it). The figures below demonstrate 2 possible first moves (note that the very first move of the game is always to remove the bottom right piece, which is the only black piece).

reversi2.png reversi3.png

The goal of the game is to clean the board (i.e. remove all pieces). Note that if the board is 1 by N, you can always win, while if the board is 2 by 2, winning is impossible (make sure you see why).

For what numbers, N and M, is a win possible?

Extra Credit: What about 3-dimensions? D-dimensions?

Thanks to Liron Raz for giving me this one.

Rabbit Season

Monday, March 1st, 2010

easyriddle.gifrabbitThere are 10 cells in a line. A transparent rabbit is in one of them. You have a shotgun, and obviously you want to shoot the rabbit.

If you hit the cell with the rabbit, you kill him (and win). Otherwise, if you shoot an empty cell, the rabbit hears the shot, gets scared of the noise and jumps one cell to the right or one cell to the left. In case the rabbit is in the right-most cell, it can only jump to the left (and similarly, if the rabbit is in the left-most cell, it jumps to the right).

Can you kill the rabbit? If so, what is the minimum number of shots needed to guarantee a kill?

Extra Credit

spoiler.gif

Spoiler Warning – read after solving the riddle above!

Instead of considering the cells in a row, the riddle can be generalized to a graph.

If the graph has cycles, no solution exists (make sure you see why!).

What happens if the graph is a general tree?

Fat Aunts

Thursday, January 14th, 2010

HousesTwo aunts are living each in her own (0-dimensional) house. There are two non-intersecting (1-dimensional) roads between the houses.

Last year, both aunts were doing a lot of exercise, and so they were slim (0-dimensional). They managed to walk together from House 1 to House 2, taking different roads, while each was holding one end of a rope of length less than L.

This year, they gained weight, and each became a sphere of radius L/2. One aunt is in House 1 and the other is in House 2. Can they exchange houses without bumping into each other (their centers must always remain on the roads)?

Really equal? Naturally!

Sunday, January 3rd, 2010

You have a set of 2N+1 natural numbers, with the following property: if you remove any one element, you can partition the remaining 2N elements into two sets A and B, each of size N, such that the sum of the N numbers in set A equals the sum of the N numbers in set B. Prove that all the numbers in the original set are equal.

Try to solve the riddle in the more general case, where the numbers are not necessarily natural, but arbitrary reals (some knowledge of algebra is helpful here).

Il Buono, il Brutto, il Cattivo

Sunday, July 5th, 2009

Good Bad UglyFor inspirational music, click here.

Il Buono (nice and easy)

Prove that in a subset of size n+1 of the set {1,2,…,2n} there are two numbers such that one divides the other.

Il Cattivo (beautiful and hard)

Prove that in a sequence of r*s+1 distinct numbers, there is either a monotonically increasing sub-sequence of length r+1 or a monotonically decreasing sub-sequence of length s+1.

Il Brutto (just easy)

Prove that in a subset of size n+1 of the set {1,2,…,2n} there are two relatively prime numbers (i.e. numbers whose gcd is 1).

Il Non Collegato (another easy one)

Prove that a degree 7 polynomial with integer coefficients, that receives the values +1 or -1 on 7 integer points is irreducible over the integers.

Unusually, I decided to omit the second page, so post your solution related comments below.

Monty Hall Revised

Friday, December 19th, 2008

This riddle is my take on the Monty Hall problem. If you know the original version, this one should be very easy for you.

You are watching the TV series “Lets Make a Deal”.

lets_make_a_deal.gif

You are very excited as you know your friend Heidi is participating today. You watch attentively throughout the show, only to find out that it ends without Heidi ever appearing in it.

You call Heidi, several times during the following day, but you keep getting her answering machine. Maybe something happened to her?

You recall the Rules of the Show:

The host presents to each candidate three closed doors. Behind one of these doors hides a big prize, behind the other two there is an empty bucket. The candidate chooses one of the doors (this choice is random as he has no information whatsoever on the location of the prize). Then the host opens one of the other doors behind which there is no prize. Then the candidate is given the option to remain with his initial choice or to switch doors and choose the other closed door. Then the remaining doors are opened, and the candidate is awarded whatever is behind the door finally chose. The goal of the candidate is (obviously) to choose the door with the prize.

Pondering about the rules, you develop the following theory:

Maybe the host does not know in advance which of the doors contains the prize. In that case, if the host happens to choose to reveal the door with the prize (thus ruining the show) the candidate is killed (finally, some proper riddle scenario) and his scene is cut-out during the editing of the show.

Maybe that is what happened to Heidi?

Assuming you have a lot of episodes (as many as you need), how can your theory be ruled out or strengthened?

Hats in a Line

Sunday, November 16th, 2008

hats_small2.jpgThis riddle is a very cool extension of a well known (and easy) riddle, involving people with hats waiting in a line.

So, lets begin with the original:

The Original Riddle

100 men are standing in a line, such that each of them sees all those that are in-front of him (so the last man sees the 99 others, etc.). Each guy has a hat on his head colored either black or white. Each of the men guesses the color of his own hat, out-loud. The guy standing last (the one that sees all the other ones) guesses first, then the guy in-front of him, etc. The men’s task is to make sure no more than one of them is wrong.

Just to make things explicit – the men are allowed to agree upon an algorithm before actually being given the hats, but once the task starts they cannot communicate in any way other than the fact that each of them hears the guess of the guys standing behind him.

Also, to conform to the universal standards of riddles, note that should more than one man be mistaken, they will all be brutally killed.

If you do not know this riddle yet, take a minute to think about its solution before reading on.

The Solution of the Basic Riddle

I give here the solution of the basic riddle so that there are no misunderstandings regarding the much more interesting extension. It goes like this – The last man (the one that guesses first) sacrifices himself (with a probability of 0.5). He regards each black hat as a 1 and each white hat as a 0. He then guesses out-loud that he has a black hat if the sum of all the hats of the other people is odd, and guesses white otherwise. The other people can all guess correctly (make sure that you understand why).

Some Trivial Extensions

Obviously the numbers 100 and 2 (the number of possible hat colors) in the original riddle are completely arbitrary. If m,n are two natural numbers then the riddle with m men and n possible hat colors is a trivial generalization of the previous result.

Now, note that if we let n, the number of possible hat colors, be equal to infinity (well, aleph 0, the cardinality of the set of natural numbers) then again we have a trivial generalization (make sure you see why).

The Real Deal

Now the extension of the riddle we are interested in consists of letting m, the number of people, be equal to aleph 0. For simplicity, lets assume that n equals two (the hats are either black or white).

Is the riddle still solvable? I.e. can the men devise an algorithm such that there will be only one mistake?

As usual, post solution related comments to the second page.

Valid Planar Pairing

Saturday, November 24th, 2007

pairing_icon.gifThere are 100 red dots and 100 blue dots on the plane (a lot of planar riddles lately). The dots are arranged such that no three are on the same line.

pairing of the red dots and the blue dots is a one-to-one function that assigns one blue dot to each red dot.

A valid pairing is a pairing such that when paired dots are connected with a straight line segment, no line intersections occur. This is depicted here:

pairing.gif

Prove that there exists a valid pairing.

I do not really like the solution I found for this riddle. If you find an elegant one, please post it.

Thanks to Nadav Sherman for giving me this one.

Uncountable Union

Wednesday, November 21st, 2007

easyriddle.gifA very interesting riddle for those of you with some basic background in Set Theory.

Prove or Disprove the Following Claim:

There exists a subset B of P(N), such that |B| = A, and B is completely ordered by the subset relation.

Notes:

N denotes the set of natural numbers.

A denotes the cardinality of the continuum (i.e. A = aleph = 2^aleph 0).

“B is completely ordered by the subset relation” means that for every two elements a, b of B, either a is a subset of b or b is a subset of a.

Expanding Frogs

Wednesday, November 21st, 2007

frog.jpgA very easy riddle. Four frogs are sitting on the corners of the unit square (i.e. they have coordinates (0,0), (0,1), (1,1) and (1,0) ). Each turn, a frog can jump over any other frog, thereby transferring itself to the symmetrical point on the other side of the static frog. For example, if the frog at (0,0) jumps over the frog at (1,1) it will land on (2,2).

easyriddle.gifProve that the frogs cannot transfer themselves to a square with a side of length 2.

I know of two different solutions to this one (both easy ;-) ).

Thanks to Nadav Sherman for asking me this riddle.

Peons

Monday, November 5th, 2007

peons_explain.jpg This is a cute puzzle. Consider an infinite checkerboard divided in two with an infinite line lying along the x-axis, as depicted below:

peons_board.jpg

You have several peons at your disposal. In each turn you can move the peons by making one of them jump over the other, thereby killing it (removing it from the board). The peon movement is demonstrated here:

peons_explain.jpg

When the game starts, all the peons are below the line. Your goal is to place a peon above the line. The example shows how to accomplish this starting with two peons. Indeed it is obvious that in order to make a peon cross the line, two peons are needed (clearly one is not enough as it cannot move at all).

How many peons are needed in order to not only cross the line, but place a peon two squares above it? As is demonstrated below, four peons are sufficient, and indeed this is the minimum (check that you see why 2 and 3 peons cannot do it).

peons_one_square.jpg

Now for the riddle. How many peons are needed (again, starting below the line) in order to place a peon 5 squares above the line?

Find the Duplicate

Saturday, October 13th, 2007

Dany Valevsky gave me this very cool riddle.

You are given a vector of size N, the elements of which are numbers in the range 1,…,N-1. I.e. there is at least one repeating element. Give an algorithm that finds a repeating element (it does not matter which one, in case there are several) with O(N) time complexity and O(1) memory complexity.

NOTE - the time and memory complexities are calculated in integers. I.e. the input is of size N, not N*logN.

That’s it!

Pirates!

Saturday, October 13th, 2007

easyriddle.gifA ship in the plane has integer coordinates. It also has integer velocity (again in ZxZ). Each turn the ship advances according to its velocity. Here is an example of a ship with velocity (3, 1).

pirates.gif

You, as a pirate, want to blow up the ship. You do not know the original position of the ship nor its velocity. You can only shoot one bomb per turn, which blows up exactly one point of the plane. What strategy should you employ in order to be sure you will eventually hit the ship?

It is very recommended to watch to this video while solving the riddle. It provides great inspiration!

Thanks to Nadav Sherman for giving me this riddle.

Piece of Cake

Thursday, August 23rd, 2007

In this article you will find a collection of riddles. They are all either very well known or extremely easy. Enjoy!

Cutting the Cake

cake1.jpgHow can you cut a circular cake to eight even pieces with 3 cuts? What is the maximum number of pieces possible with 4 cuts?

Colorblind Pills

red_or_blue_pill.jpgYou have a rare and fatal disease. The only cure for your disease is taking one Biaxin pill (which is blue) and one Robaxin pill (which is red) exactly at midnight, for two days. I.e. you have to take one of each today at midnight and one of each tomorrow at midnight, for a total of four pills. You have exactly four pills (two of each kind) at your disposal. The pills, apart from being in different colors, are identical in appearance.

Now, in addition to your fatal illness, you are also colorblind. How can you save yourself?

Note that in order to be saved you have to take the pills exactly as described above – e.g. taking all four pills at the same time will get you killed!

And no - there aren’t other people that can help you, etc…

Cup of Coffee, Fuck of Tea 

glass-of-milk.jpgYou have a cup of coffee and a cup of milk, both containing the same (unspecified) amount of liquid. You take one spoon full of milk and put it in the coffee. You mix well. You then return a spoon full of the mixture to the cup of milk. Which is more: milk in coffee or coffee in milk?

The title is taken from the famous Israeli movie Operation Grandma. Thanks to Misha Seltzer for this riddle.

The Virgin Islands

british_virgin_islands_property.jpg You are shipwrecked on the Virgin Islands (since Chuck Norris visited them, they are known simply as The Islands). You know that there are three tribes in the Islands: The Liatu tribe, that always lies, the Honestu tribe, that always tells the truth, and the Randomu tribe that answers randomly to every question asked. As you wander around the Islands, you come across 3 tribesmen. By the way they are dressed you can tell that they belong to different tribes (i.e. there is one member of each tribe) but you do not know to which tribe they belong. The native language on the Islands is French, which you speak fluently. It is well known that in French you can only ask “yes-no” questions. You are also familiar with an ancient tradition on the Islands, that says that it is impolite to ask more than 2 questions (each addressed to one specific person) per conversation, no más. You are standing at a fork and need to decide whether to go left or right. How can you get your information?

23 and 2000

Monday, August 13th, 2007

easyriddle.gifYou are given 23 whole numbers, not necessarily distinct, in a row.

You cannot change the order of the numbers.

Prove that there exists an arrangement of the symbols ’+’, ‘×’, ‘(‘ and ‘)’ in-between the 23 numbers, such that the final result is a valid formula, whose evaluated value equals 0 mod 2000.

Extra Credit 

  1. Is 23 a tight bound? Can you find a sequence of 22 numbers such that all arrangements of the symbols ‘+’, ‘×’, ‘(‘ and ‘)’ in-between them will result in numbers that are different from 0 mod 2000? I haven’t thought about this one yet, so please post your ideas!
  2. Consider a more general case. Replace in the riddle above the number 23 by K and the number 2000 by N. Describe all the pairs, K, N, for which a solution to the riddle exists.

Thanks to Misha Seltzer, for sending me this cool riddle!

You are in my Seat!

Wednesday, July 25th, 2007

plane_seats.jpg There are 100 seats in an airplane.

There are 99 male passangers with reserved seats and one female passager that does not have a ticket.

The female passanger enters the plane first, selects a random seat (out of the total 100 seats) and sits in it.

Then the first man enters. If his seat is not taken he sits in it. If it is taken he selects a non-occupied random seat in the plane and sits there.

The rest of the men enters and does the same – each of them first tries to take his own seat (if it is available) and otherwise sits in a random non-occupied seat.

What is the probability that the last man to enter the plane gets his original seat?

easyriddle.gif

Blindfolded Flipping

Wednesday, July 25th, 2007

blindfold_small.gif There are 100 coins on the table. 90 of the coins have their Heads face up, the other 10 have their Tails face up. Your task is to split the coins into two groups, such that both groups contain the same number of coins with their Heads face up. You are even allowed to flip the coins…

The catch is that you cannot see the coins – you are blindfolded!

What is your strategy?

easyriddle.gif

Spot The Not

Wednesday, July 25th, 2007

This one is a riddle of my own invention. It gives a very good counter-example to something we tend to take for granted. Do not be discouraged – I posed it to one of my smartest professors and he did not find the answer! (at least not in the first five minutes…).

The riddle requires some knowledge of Topology and Real-Analysis.  For those of you lacking it, all the relevant definitions are included at the end (I recommend skimming through them before reading the riddle itself).

This seemingly trivial list of claims leads to a contradiction. Can you find the error?

  1. If A is an open subset of R, the R-A is a closed subset.
  2. If A is a subset of R, then bdy(A) = bdy(R-A).
  3. If T is the set of all irrational numbers in the segment [0,1], then u(A) = 1 (u is the Lebesgue measure).
  4. There exists a closed set B contained in the set T (T as in 3) such that u(B) > 0.9.
  5. If A is an open subset of R, then A is a countable union of open intervals.
  6. If I is an open interval then bdy(I) contains at most 2 points.
  7. From 5 and 6 it follows that if A is an open subset of R, then bdy(A) is countable.
  8. From 1, 2 and 7 it follows that if A is a closed subset of R then bdy(A) is countable.
  9. From 8 it follows that if A is a closed set then u(A) = u(A-bdy(A)).
  10. From 9 it follows that u(B-bdy(B)) > 0.9 (where B is as in 4).
  11. Let C=B-bdy(B). Then C is an open set contained in T with u(C) > 0.9. This is clearly impossible since the only open set contained in T is the empty set with Lebesgue measure of 0!

Can you “Spot the Not”?

Definitions Used by the Riddle

  1. Open set – a set is called open if each point of the set is an interior point of the set.
  2. Interior point - a point p is called an interior point of a subset A of R if there exists e>0 such that the interval (c-e,c+e) is contained in A.
  3. Closed set – a set is called closedif the limit of every converging sequence contained in the set is also in the set. It can  be shown that if A is an open set in R, then R-A is a closed set in R, and vise-versa. This is actually very easy - try to prove it!
  4. Measure of an interval – the measure of an interval I=(a,b) is denoted m(I) and is equal to b-a.
  5. Lebesgue outer measure – let A be a subset of R. The Lebesgue outer measure of A is defined as inf { Σm(Pi) | Pi are countably many open intervals and A is contained in union of the Pis }. Those of you unfamiliar with the definition of the Lebesgue measure, can replace the occurrences of Lebesgue measure with Lebesgue outer measure in the claims above.
  6. Boundary – the boundary of a subset A of R, denoted bdy(A) is the set { x | for all e>0, (x-e,x+e) ∩ A, contains both a point from A and from R-A }.

Good luck!

lebesgue.gif

What are the Odds?

Friday, July 20th, 2007

coin.gifThis is the first riddle I post in my site that I haven’t yet solved.

Because of this, I give it the “very hard” icon. It may turn out to be easy – do not be intimidated!

veryhard.gif

You are given a natural number N and two coins. You can set the probabilities of getting heads or tails on both coins as you wish. You are then asked to generate a random number uniformly distributed on the set { 1, 2, …, N }. The catch is that you must have a finite upper bound on the number of coin tosses you use.

Lets clarify the requirements of the riddle by a simple example. Say N=6. Setting the probabilities for the coins to 2/3 and 1/2 will do the trick, as we can generate a number uniformly distributed on the set { 1, 2, 3, 4, 5, 6 } with a maximum of 3 tosses of the two coins (can you see how?).

Good luck! 

Ants Revamped

Thursday, June 14th, 2007

ant-drawing2.jpgPlease make sure you have read (and solved) the original Ants riddle before reading on!

 easyriddle.gif

Here are two sequel questions to the original Ants riddle:

  1. Which is the last ant to fall off the stick?
  2. What is the maximum number of ant collisions possible?

I want to thank Danny Valevsky for bringing these to my attention!

Divide and Conquer

Saturday, June 9th, 2007

divide_and_conquer.gif Yesterday, Zohar Gilboa, with whom I take a PDE course, asked me the following riddle. I must admit it is probably the riddle I like the least on my site thus far. It is very easy though, and as Zohar told me he really liked it himself, I decided to publish it anyways.

Consider the following image:

divide_and_conquer.gif

Your goals are:

  1. Divide shape 1 (bluish) to two equal parts.
  2. Divide shape 2 (greenish) to three equal parts.
  3. Divide shape 3 (yellowish) to four equal parts.
  4. Divide shape 4 (purplish) to five equal parts.

All the division parts mentioned should be continuous shapes.

The second page contains the solution! Please only visit it after giving the riddle some thought…

Two Envelopes

Saturday, June 2nd, 2007

EnvelopesYou write down 2 numbers on 2 pieces of paper (one number on each piece). You put each paper in a sealed envelope. I choose one of the envelopes randomly and open it. I then carry out a certain procedure at the end of which I know with a probability greater than 1/2 whether I received the larger or the smaller of the numbers. I can do this even if when you initially wrote down the numbers, you knew my decision procedure!

How can I do that? What is my trick?

Guess my Number

Saturday, May 26th, 2007

easyriddle.gifWell, it is time for a cool and easy riddle. 100 men are each assigned a number between 1-100 with repetitions (e.g. all of them may be assigned the number 17). Each of the men sees all the numbers assigned to all the other 99 men, but none of them sees the number assigned to himself.

Each of them needs to guess his own number (of course no information is exchanged between them – no one hears what others have guessed etc.). What strategy can they employ in order to make sure at least one of them makes a correct guess?

Some followup thoughts:

  • Can they make sure more than one person succeeds?
  • How many different solutions to the riddle are there (i.e. how many strategies can the men employ?).

Whole Rectangles

Friday, May 25th, 2007

veryhard.gifA short introduction to Graph Theory is needed for this one. If you already are familiar with Graph Theoretic constructs feel free to skip it.

A graph G, is a pair (V,E) where V is a set of vertices and E is a set of edges. Each edge is an unordered pair of the form (u, v) where u and v are vertices (i.e. they belong to V). The degree of a vertex t (denoted deg(t)) is the number of edges containing it:

deg(t) = #{ e | e = (s, t) ^ s belongs to V }

In this post I only consider finite and simple graphs. A finite graph is a graph whose vertex-set V is a finite set. A simple graph is a graph in which there are no loops (i.e. edges of the form (u, u)) and no multiple edges (i.e. E is a proper set so it cannot contain the same element twice).

The following is a trivial claim:

The sum of the degrees in a graph equals twice the number of edges.

It is trivial to prove this claim by induction on the number of edges (on a graph with no edges it is clear, and by adding an edge to the edge set of the graph the sum of degrees increases by two).

Use this claim to solve the following riddle:

A rectangle is called whole if at least one of its sides is an integer. For example, a rectangle of 2 by 3/5 is whole as well as a rectangle of sqrt(5) by 3. A rectangle of 1/2 by 1/2 is not whole. Examples:

Rectangle Exmaple

A set T of rectangles constitues a tiling of a rectangle R if the rectangles in T are disjoint and for every point p in R there is a rectangle S in T such that p belongs to S. Example:

Tiling Example

Prove that if R is a rectangle and T is a tiling of R consisting only of whole rectangles (i.e. every rectangle S in T is whole) then R is whole.

Smart Disagreement

Wednesday, May 23rd, 2007

DiceThis one is a riddle of my own invention. I am really proud of it as it sounds impossible at first, but it can be resolved in a very satisfying fashion. I must admit that had I heard about it from someone else I would not have gone through the trouble of trying to solve it, as it sounds like a ”cheap-trick” riddle. I can only ask you to trust me that it is indeed a purely mathematical riddle. Although it did provoke several harsh disputes with some very smart people (Matan, Eyal, how are you guys?), I was able to finally convince them of the mathematical validity of my solution.

The riddle goes like this:

A group of very smart men perform an experiment. There are no restrictions on the men’s behaviour during the experiment. After the experiment is over, each of the men reveals to all the others everything that he knows. Despite the fact that none of the men lies and they all know of everything that happened, there are 2 individuals in the group that reach different scientific conclusions. Your task is to devise such an experiment.

Note that the experiment is scientific in that it does not concern individual tastes or opinions. All the men are assumed to come from similar backgrounds and have similar likings. The different conclusions regard real aspects of nature.

The dice picture is a (vague) reference to one variant of my solution.

Perl vs. Python One-Liner

Sunday, May 20th, 2007

A few years ago a friend of mine asked me the following Perl riddle. Unfortunately, in order to solve it you must know Perl. As I like Python much better, I translated the riddle to Python. Attached are both versions.

I admit the Perl version is a bit more cryptic and if you know both Perl and Python you should try to solve the Perl version (but use Python for everything else in life :-) ).

Oh, and try to solve the riddle without running it (run it only as a last resort).

Perl Logo

perl -wle 'print "True" if (1 x shift) !~ /^1?$|^(11+?)\1+$/' [number]

Python Logo

python -c "import sys, re; print None == re.match('^1?$|^(11+?)\\1+$','1'*int(sys.argv[1]))" [number]

To alleviate all doubt – [number] denotes a numeric command line argument (e.g. 17).

Find Your Name

Sunday, May 13th, 2007

I had a lot of thinking before deciding to include this riddle in my site. The argument for not including it, is that it is too complicated. I ended up deciding it deserves its place in my riddles section (which means I believe it is one of the most beautiful riddles ever) because, well, I think it is one of the most beautiful riddles ever. So enjoy! (but be ready for a hard one…):

veryhard.gif

There are 100 men, 100 boxes and 100 notes with the men’s names on them. The 100 boxes are arranged in a line in a room. Each of the notes with the names is put in a different box randomly. The men are put together and are allowed to decide upon a strategy. When they are done, they are taken, each in his turn, to the room with the boxes. Each one is allowed to open 50 of the boxes. No information whatsoever is shared between the men.

The goal of the men is that each of them finds his own name among the 50 boxes he opened. If but one of them fails to find his own name, they all get killed (why is it, that in so many riddles people end up dead?). You are required to find a method with which they are all saved with a probability of above 30%.

If you understood this riddle properly, it should seem impossible to you at first.

Because the riddle contains many details and to make sure I explained it properly, lets consider two bad strategies for the men:

1. All the men decide to open the same 50 boxes – this is probably the worst strategy for them, as all of them will die with probability 1. This is because 50 of them are sure not to find their names in the boxes they open.

2. Every man open 50 boxes randomly – although a better strategy than the former one, it is a very bad strategy. Each person is likely to find his own name with a probability of 1/2. As all the events of the men finding their names are independent, they will be saved with a probability of (1/2)^100.

As this number is smaller than 0.00000000000000000000000000000079 (which is obviously smaller than 30%) it is a very bad strategy indeed.

BTW - to calculate the above number I used the following python statement:
>>> '%1.32f'%0.5**100

Solution now available on next page!

Ants

Friday, May 11th, 2007

This is probably the best riddle I know of.

There are 1000 ants walking on a horizontal stick, 1m long.

Each ant is walking at a constant rate of 1m/hour.

The ants start out in random locations on the stick, some walking to the left and some to the right.

Whenever two ants meet they reverse their direction, as follows:

Riddle Illustration

Whenever an ant reaches one of the ends of the stick, it falls off (eventually all ants will fall).

What is the longest time it will take the last ant to fall off the stick?

The Ants riddle is one of the best riddles ever. It requires an imaginative mind, but does not require any knowledge of mathematics. A talented 6 year old can solve it!That is not to say it is very easy, but you can solve it yourself. DO NOT DESPAIR!

If you already solved the riddle and want to see the solution – visit the second page below.