Archive for the ‘Puzzles’ Category.

The Cookie Monster Problem

by Olivier Bernardi and Tanya Khovanova

The Cookie Monster is a peculiar creature that appeared in The Inquisitive Problem Solver (Vaderlind, Guy & Larson, MAA, P34). Presented with a set of cookie jars, the Cookie Monster will try to empty all the jars with the least number of moves, where a move is to select any subset of the jars and eat the same number of cookies from each jar in the subset.

Even an untalented Cookie Monster would be able to empty n jars in n moves: to fulfill this strategy the Monster can devour all the cookies of one jar at a time. If the Monster is lucky and some jars have the same number of cookies, the Monster can apply the same eating process to all these identical jars. For example, if all the jars have the same number of cookies, the Monster can gulp down all of them in one swoop.

Now, let us limit our discussion to only cases of n non-empty jars that contain distinct numbers of cookies. If indeed all the numbers are distinct, can the Monster finish eating faster than in n moves?

The answer depends on the actual number of cookies in each jar. For example, if the number of cookies in jars are different powers of 2, then even the most talented Monsters can’t finish faster than in n steps. Indeed, suppose the largest jar contains 2N cookies. That would be more than the total number of cookies in all the other jars together. Therefore, any strategy has to include a step in which the Monster only takes cookies from the largest jar. The Monster will not jeopardize the strategy if it takes all the cookies from the largest jar in the first move. Applying the induction process, we see that we need at least n steps.

On the other hand, sometimes the Monster can finish the jars faster. If 2k−1 jars contain respectively 1, 2, 3, …, 2k−1 cookies, the Cookie Monster can empty them all in k steps. Here is how. For its first move, the Monster eats 2k-1 cookies from each of the jars containing 2k-1 cookies or more. What remains are 2k-1−1 pairs of identical non-empty jars containing respectively 1, 2, 3, …, 2k-1−1 cookies. The Monster can then continue eating cookies in a similar fashion, finishing in k steps. For instance, for k=3 the sequences of non-empty jars are: 1,2,3,4,5,6,7 → 1,1,2,2,3,3 → 1,1,1,1 → all empty.

Now we would like to prove a theorem that shows that the example above is the lowest limit of moves even for the most gifted Cookie Monsters.

Theorem. If n non-empty jars contain distinct numbers of cookies, the Cookie Monster will need at least ⌈log2(n+1)⌉ steps to empty them all.

Proof. Suppose that n jars contain distinct numbers of cookies and let f(n) be the number of distinct non-empty jars after the first move of the Cookie Monster. We claim that n ≤ 2f(n)+1. Indeed, after the first move, there will be at least n − 1 non-empty jars, but there cannot be three identical non-empty jars. That means, the number of jars plus 1 can’t decrease faster than twice each time.

Now here is something our readers can play with. Suppose a sequence of numbers represents the number of cookies in the jars. Which sequences are interesting, that is, which can provide interesting solutions for the Cookie Monster problem?

Share:Facebooktwitterredditpinterestlinkedinmail

How Many Hats Can Fit on Your Head?

Lionel Levine invented a new hat puzzle.

The sultan decides to torture his hundred wise men again. He has an unlimited supply of red and blue hats. Tomorrow he will pile an infinite, randomly-colored sequence of hats on each wise man’s head. Each wise man will be able to see the colors of everyone else’s hats, but will not be able to see the colors of his own hats. The wise men are not allowed to pass any information to each other.
At the sultan’s signal each has to write a natural number. The sultan will then check the color of the hat that corresponds to that number in the pile of hats. For example, if the wise man writes down “four,” the sultan will check the color of the fourth hat in that man’s pile. If any of the numbers correspond to a red hat, all the wise men will have their heads chopped off along with their hats. The numbers must correspond to blue hats. What should be their strategy to maximize their chance of survival?

Suppose each wise man writes “one.” The first hat in each pile is blue with a probability of one-half. Hence, they will survive as a group with a probability of 1 over 2100. Wise men are so wise that they can do much better than that. Can you figure it out?

Inspired by Lionel, I decided to suggest the following variation:

This time the sultan puts two hats randomly on each wise man’s head. Each wise man will see the colors of other people’s hats, but not the colors of his own. The men are not allowed to pass any info to each other. At the sultan’s signal each has to write the number of blue hats on his head. If they are all correct, all of them survive. If at least one of them is wrong, all of them die. What should be their strategy to maximize their chance of survival?

Suppose there is only one wise man. It is clear that he should write that he has exactly one blue hat. He survives with the probability of one-half. Suppose now that there are two wise men. Each of them can write “one.” With this strategy, they will survive with a probability of 1/4. Can they do better than that? What can you suggest if, instead of two, there is any number of wise men?

Share:Facebooktwitterredditpinterestlinkedinmail

Subtleties of Lies

In a puzzle book by Mari Berrondo (in Russian), I found the following logic problem:

Alfred, Bertran and Charles are asked about their profession. One of them always lies; another one always tells the truth; and the third one [who I will refer to as a “half-liar”] sometimes lies and sometime tells the truth. Here are their answers:

Bertran: I am a painter, Alfred is a piano-tuner, Charles is a decorator.
Alfred: I am a doctor, Charles is an insurance agent. Concerning Bertran, if you ask him, he will tell you that he is a painter.
Charles: Alfred is a piano-tuner. Bertran is a decorator, and I am an insurance agent.
What is the profession of the half-liar?

The solution in the book is the following. As Alfred is right about what Bertran would say, Alfred can’t be a liar. If Alfred is a half-liar then the other two people would give the opposite statements, since one will be a truth-teller and the other a liar. But they both say that Alfred is a piano-tuner, therefore Alfred must be a truth-teller. Hence, Alfred’s statement about everyone’s profession must be the truth. Now we know that Charles is an insurance agent. As Charles confirms that, thus telling the truth in this instance, we recognize that he must be a half-liar. The answer to the problem is that the half-liar is an insurance agent.

But I have a problem with this problem. You see, a liar can say many things. He can say that he is a conductor, a mathematician, a beekeeper or whatever. So there is no way of knowing what a person who decides to lie can say. Let’s just analyze the statement by Alfred: “Concerning Bertran, if you ask him, he will tell you that he is a painter.”

If Alfred tells the truth about what Bertran would say, he needs to know for sure that Bertran will say that he is a painter. Hence, Bertran must be a truth-teller and a painter. If Alfred lies, he needs to be sure that Bertran won’t say that he is a painter. So Bertran must be either a truth-teller and not a painter, or a liar and a painter. Bertran can’t be a half-liar, because a half-liar can say that he is a painter as well as he can say something else, no matter what his real profession.

There is one interesting aspect of this that many people overlook. There are different types of people who are half-liars. In some books half-liars are introduced as people who, before making a statement, flip a coin to decide whether to lie or to tell the truth. Such a person needs to know in advance exactly what other people are saying, in order to construct a statement about what those people might say that corresponds to the coin flip. On the other hand, other types of half-liars exist. One half-liar can say something and then see later whether it is true. If Alfred is a half-liar who doesn’t care in advance about the truth of his statement, he can say that Bertran will claim that he is a painter.

I leave it to my readers to finish my analysis and see that the problem doesn’t have a solution. To end my essay on a positive note, I decided to slightly change the problem, so that there is no contradiction. In the same setting:

Bertran: I am a painter, Alfred is a piano-tuner, Charles is a decorator.
Alfred: I am a doctor, Charles is an insurance agent. Concerning Bertran, if you ask him, he will tell you that he is not a painter.
Charles: Alfred is a piano-tuner. Bertran is a decorator, and I am an insurance agent.
What is the profession of the half-liar?

Share:Facebooktwitterredditpinterestlinkedinmail

The Horsemen Sequences

33 horsemen are riding in the same direction along a circular road. Their speeds are constant and pairwise distinct. There is a single point on the road where the horsemen can pass one another. Can they ride in this fashion for an arbitrarily long time?

The puzzle appeared at the International Tournament of the Towns and at the Moscow Olympiad. Both competitions were held on the same day, which incidentally fell on Pi Day 2010. Just saying: at the Tournament the puzzle was for senior level competitors; at the Moscow Olympiad it was for 8th graders.

Warning: If you want to solve it yourself first, pause now, because here is the solution I propose.

First, consider two horsemen who meet at that single point. The faster horseman passes the slower one and gallops ahead and the slower one canters along. The next meeting point should be at the same place in the circle. Suppose the slower horseman rides n full circles before the next meeting, then the second horseman could not have passed the first in between, so he has to ride n+1 full circles. That means their speeds should have a ratio of (n+1)/n for an integer n. And vice versa, if their speeds have such a ratio, they will meet at the same location on the circle each time. That means that to solve the problem, we need to find 33 different speeds with such ratios.

As all speed ratios are rational numbers, we can scale speeds so that they are relatively prime integers. The condition that two integers have a ratio (n+1)/n is equivalent to the statement that two integers are divisible by their difference. So the equivalent request to the problem is to find a set of 33 positive integers (or prove non-existence), such that every two integers in the set are divisible by their difference.

Let’s look at examples with a small number of horsemen. For two riders we can use speeds 1 and 2. For three riders, speeds 2, 3 and 4.

Now the induction step. Suppose that we found positive integer speeds for k horsemen. We can add one more horseman with zero speed who quietly stays at the special point and everyone else passes him. The difference condition is satisfied. We just need to tweak the set of speeds so that the lazy horseman starts moving.

We can see that if we add the least common multiple to every integer in a set of integers such that every two numbers in a pair are divisible by their difference, then the condition stays satisfied. So by induction we can find 33 horsemen. Thus, the answer to the problem is: Yes they can.

Now I would like to apply that procedure from the solution to calculate what kind of speeds we get. If we start with one rider with the speed of 1, we add the second rider with speed 0, then we add 1 to both speeds, getting the solution for two riders: 1 and 2. Now that we have a solution for two riders, we add a third rider with speed 0 then add 2 to every speed, getting the solution for three horsemen: 2, 3 and 4. So the procedure gave us the solutions we already knew for two and three horsemen.

If we continue this, we’ll get speeds 12, 14, 15 and 16 for four riders. Similarly, 1680, 1692, 1694, 1695, and 1696 for five riders.

We get two interesting new sequences out of this. The sequence of the fastest rider’s speed for n horsemen is: 1, 2, 4, 16, 1696. And the sequence of the least common multiples for n−1 riders — which is the same as the lowest speed among n riders — is: 1, 1, 2, 12, 1680, 343319185440.

The solution above provides very large numbers. It is possible to find much smaller solutions. For example for four riders the speeds 6, 8, 9 and 12 will do. For five riders: 40, 45, 48, 50 and 60.

I wonder if my readers can help me calculate the minimal sequences of the fastest and slowest speeds. That is, to find examples where the integer speed for the fastest (slowest) horseman is the smallest possible.

Share:Facebooktwitterredditpinterestlinkedinmail

Puzzles for Lawyers

One day we may all face the necessity of hiring a lawyer. If the case is tricky the lawyer must be smart and inventive. I am collecting puzzles to give to a potential lawyer during an interview. The following puzzle is one of them. It was given at the second Euler Olympiad in Russia:

At a local Toyota dealership, you are allowed to exchange brand new cars. You can exchange three Camrys for one Prius and one Avalon, and three Priuses for two Camrys and one Avalon. Assuming an unlimited supply of cars at the dealership, can collector Vasya exchange 700 Camrys for 400 Avalons?

The beauty of this puzzle is that the answer I may find acceptable from a mathematician is not the same as I want from my future lawyer.

Have I intrigued you? Get to work and send me your solutions.

Share:Facebooktwitterredditpinterestlinkedinmail

Fermat’s Room

Most movies related to mathematics irritate me because of simplifications. I especially do not like when a movie pretends to be intelligent and then dumbs it down. I recently watched the Spanish movie Fermat’s Room, which, as you may guess, annoyed me several times. In spite of that I enjoyed it very much.

The movie opens with people receiving invitations to attend a meeting for geniuses. To qualify for the meeting they need to solve a puzzle. Within ten days, they must guess the order underlying the following sequence: 5, 4, 2, 9, 8, 6, 7, 3, 1. Right away, at the start of the movie, I was already annoyed because of the simplicity of the question. You do not have to be a genius to figure out the order, not to mention how easy it would be to plug this sequence into the Online Encyclopedia of Integer Sequences to find the order in five minutes.

The participants were asked to hide their real names, which felt very strange to me. All famous puzzle solvers compete in puzzle championships and mystery hunts and consequently know each other.

The meeting presumably targets the brightest minds and promises to provide “the greatest enigma.” During the meeting they are given seven puzzles to solve. All of them are from children’s books and the so-called “greatest enigma” could easily be solved by kids. Though I have to admit that these were among the cutest puzzles I know. For example:

There are three boxes: one with mint sweets, the second with aniseed sweets, and the last with a mixture of the two. The boxes are labeled, but all the labels are wrong. What is the minimum number of sweets you need to taste to correctly re-label all the boxes?

Another of the film’s puzzles includes a light bulb in a room and three switches outside, where you have to correctly find the switch that corresponds to the bulb, but you can only enter the room once. In another puzzle you need to get out of prison by deciding which of two doors leads to freedom. You are allowed to ask exactly one question to one of the two guards, one of whom is a truth-teller and the other is a liar.

The other four puzzles are similar to these three I have just described. To mathematicians they are not the greatest enigmas. They are nice material for a children’s math club. For non-mathematicians, they may be fascinating. Certainly it’s a good thing that such tasteful puzzles are being promoted to a large audience. But they just look ridiculous as “the greatest enigmas.”

So what is it about this film that I so enjoyed?

The intensity of the movie comes from the fact that the people are trapped in a room that starts shrinking when they take more than one minute to solve a puzzle.

I well remember another shrinking room from Star Wars: A New Hope. When Princess Leia leads her rescuers to a room, it turns out to be a garbage compactor. The bad guys activate the compactor and two opposite walls start moving in. In contrast, Fermat’s room is shrinking in a much more sophisticated way: all four walls are closing in. Each of the walls in the rectangular room is being pressured by an industrial-strength press. The walls in the corners do not crumble, but rather one wall glides along another. I was more puzzled by this shrinking room than I was by the math puzzles. I recommend that you try to figure out how this can be done before seeing the movie or its poster.

However, the best puzzle in the movie is the plot itself. Though I knew all the individual puzzles, what happened in between grabbed me and I couldn’t wait to see what would happen next. I saw the movie twice. After the first time, I decided to write this review, so I needed to check it again. I enjoyed it the second time even better than the first time. The second time, I saw how nicely the plot twists were built.

Maybe I shouldn’t complain about the simplicity and the familiarity of the puzzles. If they were serious new puzzles I would have started solving them instead of enjoying the movie. The film’s weakness might be its strength.

Share:Facebooktwitterredditpinterestlinkedinmail

The Wizards’ Hats

I collect hats puzzles. A puzzle about hats that I hadn’t heard before appeared on the Konstantin Knop’s blog (in Russian):

The sultan decides to test his hundred wizards. Tomorrow at noon he will randomly put a red or a blue hat — for both of which he has an inexhaustible supply — on every wizard’s head. Each wizard will be able to see every hat but his own. The wizards will not be allowed to exchange any kind of information whatsoever. At the sultan’s signal, each wizard needs to write down the color of his own hat. Every wizard who guesses wrong will be executed. The wizards have one day to decide on a strategy to maximize the number of survivors. Suggest a strategy for them.

I’ll start the discussion with a rather simple idea: Each wizard writes down a color randomly. In this case the expected number of survivors is 50. Actually, if each wizard writes “red”, then the expected number of survivors is 50, too. Can you find a better strategy, with a greater expected number of survivors or prove that such a strategy doesn’t exist?

As a bonus question, can you suggest a strategy that guarantees 50 survivors?

Now that you’ve solved that issue, here’s my own variation of the problem.

The wizards are all very good friends with each other. They decide that executions are very sad events and they do not wish to witness their friends’ deaths. They would rather die themselves. They realize that they will only be happy if all of them survive together. Suggest a strategy that maximizes the probability of them being happy, that is, the probability that all of them will survive.

Share:Facebooktwitterredditpinterestlinkedinmail

Mr. Jones

The following two problems appeared together in Martin Gardner’s Scientific American column in 1959.

Mr. Smith has two children. At least one of them is a boy. What is the probability that both children are boys?

Mr. Jones has two children. The older child is a girl. What is the probability that both children are girls?

Many people, including me and Martin Gardner, wrote a lot about Mr. Smith. In his original column Martin Gardner argued that the answer to the first problem is 1/3. Later he wrote a column titled “Probability and Ambiguity,” where he corrected himself about Mr. Smith.

… the answer depends on the procedure by which the information “at least one is a boy” is obtained.

This time I would like to ignore Mr. Smith, as I wrote a whole paper about him that is now under consideration for publication at the College Mathematics Journal. I would rather get back to Mr. Jones.

Mr. Jones failed to stir a controversy from the start and was forgotten. Olivier Leguay asked me about Mr. Jones in a private email, reminding me that the answer to the problem about his children also depends on the procedure.

One of the reasons Mr. Jones was forgotten is that for many natural procedures the answer is 1/2. For example, the following procedures will produce an answer of 1/2:

  • We ask Mr. Jones whether his older child is a daughter and he says “yes.”
  • Mr. Jones flips a coin deciding which child to talk about. After that he has to tell us the gender and whether the child is the oldest.
  • Mr. Jones is asked to say nothing if he doesn’t have a daughter, to select the daughter if has just one, or to pick one at random if he has two daughters. After that he has to tell us whether the daughter he has selected is the oldest.

There are many other procedures that lead to the answer 1/2. However, there are many procedures that lead to other answers.

Suppose I know Mr. Jones, and also know that he has two children. I meet Mr. Jones at a mall, and he tells me that he is buying a gift for his older daughter. Most probably I would assume that the other child is a daughter, too. In my experience, people who have a son and a daughter would say that they are buying a gift for “my daughter.” Only people with two daughters would bother to specify that they are buying a gift for “my older daughter.”

In some sense I didn’t forget about Mr. Jones. I wrote about him implicitly in my essay Two Coins Puzzle. His name was Carl and he had two coins instead of two children.

Share:Facebooktwitterredditpinterestlinkedinmail

Tetrahedron Problems

My blog is getting more famous. Now I don’t need to look around for nice problems, for my readers often send them to me. In response to my blog about him, Sergey Markelov’s Best, Markelov sent me more of his problems. Here is a cute tetrahedron problem that he designed:

Six segments are such that you can make a triangle out of any three of them. Is it true that you can build a tetrahedron out of all six of them?

Another reader, Alexander Shen, sent me a different tetrahedron problem from a competition after reading my post on Problem Design for Multiple Choice Questions:

Imagine the union of a pyramid based on a square whose faces are equilateral triangles and a regular tetrahedron that is glued to one of these faces. How many faces will this figure have?

Shen wrote that the right answer to this problem had been rumored to have a negative correlation with the result of the entire test.

Share:Facebooktwitterredditpinterestlinkedinmail

86 Conjecture

86 is conjectured to be the largest power of 2 not containing a zero. This simply stated conjecture has proven itself to be proof-resistant. Let us see why.

What is the probability that the nth power of two will not have any zeroes? The first and the last digits are non-zeroes; suppose that other digits become zeroes randomly and independently of each other. This supposition allows us to estimate the probability of 2n not having zeroes as (9/10)k-2, where k is the number of digits of 2n. The number of digits can be estimated as n log102. Thus, the probability is about cxn, where c = (10/9)2 ≈ 1.2 and x = (9/10)log102 ≈ 0.97. The expected number of powers of 2 without zeroes starting from the power N is cxN/(1-x) ≈ 40 ⋅ 0.97N.

Let us look at A007377, the sequence of numbers such that their powers of 2 do not contain zeros: 1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 14, 15, 16, 18, 19, 24, 25, 27, 28, 31, 32, 33, 34, 35, 36, 37, 39, 49, 51, 67, 72, 76, 77, 81, 86. Our estimates predicts 32 members of this sequence starting from 6. In fact, the sequence has 30 conjectured members. Similarly, our estimate predicts 2.5 members starting from 86. It is easy to check that the sequence doesn’t contain any more numbers below 200 and our estimate predicts 0.07 members after 200. As we continue checking larger numbers and see that they do not belong to the sequence, the probability that the sequence contains more elements vanishes. With time we check more numbers and become more convinced that the conjecture is true. Currently, it has been checked up to the power 4.6 ⋅ 107. The probability of finding something after that is about 1.764342396 ⋅10-633620.

Let us try to approach the conjecture from another angle. Let us check the last K digits of powers of two. As the number of possibilities is finite, these last digits eventually will start cycling. If we can show that all the elements inside the period contain zeroes, then we need to check the finite number of powers of two until this period starts. If we can find such K, we can prove the conjecture.

Let us look at the last two digits of powers of two. The sequence starts as: 01, 02, 04, 08, 16, 32, 64, 28, 56, 12, 24, 48, 96, 92, 84, 68, 36, 72, 44, 88, 76, 52, 04. As we would anticipate, it starts cycling. The cycle length is 20, and 90% of numbers in the cycle don’t have zeroes.

Now let’s continue to the last three digits. The period length is 100, and 19 of them either start with zero or contain zero. The percentage of elements in the cycle that do not contain zero is 81%.

The cycle length for the last n digits is known. It is 4 ⋅ 5n-1. In particular the cycle length grows by 5 every time. The number of zero-free elements in these cycles form a sequence A181610: 4, 18, 81, 364, 1638, 7371, 33170. If we continue with our supposition that the digits are random, and study the new digits that appear when we move from the cycle of the last n digits to the next cycle of the last n+1 digits, we can expect that 9/10 of those digits will be non-zero. Indeed, if we check the ratio of how many numbers do not contain zero in the next cycle compared to the previous cycle, we get: 4.5, 4.5, 4.49383, 4.5, 4.5, 4.50007. All of these numbers are quite close to our estimation of 4.5. If this trend continues the portion of the numbers in the cycle that don’t have zeroes tends to zero; however, the total of such numbers grows exponentially. We can even estimate that the expected growth is 4 ⋅ 4.5n-1. From this estimation, we can derive the conjecture:

Conjecture. For any number N, there exists a power of two such that its last N digits are zero-free.

Indeed, the last N digits of powers of two cycle, and there are an increasing number of members inside that cycle that do not contain zeroes. The corresponding powers of two don’t have zeroes among N rightmost digits.

So, how do we combine the two results? First, the expected probability of finding the power of two larger than 86 that doesn’t contain zero is minuscule. And second, we most certainly can find a power of two that has as many zeroless digits at the end as we want.

To combine the two results, let us look at the sequences A031140 and A031141. We can deduce from them that for the power 103233492954 the first zero from the right occupies the 250th spot. The total number of digits of that power is 31076377936. So 250 is a tiny portion of the digits.

As time goes by we grow more and more convinced that 86 is the largest power of two without zeroes, but it is not at all clear how we can prove the conjecture or whether it can be proven at all.

My son, Sergei, suggested that I claim that I have a proof of this conjecture, but do not have enough space in the margin to fit my proof in. The probability that I will ever be shamed and disproven is lower than the probability of me winning a billion dollars in the lottery. Though then, if I do win the big bucks, I will still care about being shamed and disproven.

Share:Facebooktwitterredditpinterestlinkedinmail