Mihai's page

A puzzle that puzzled ChatGPT

Ever since my birthday started looming on the horizon, I got this idea of a puzzle. Since the news cycle contained, among other things, a lot of GPT and LLM-based AI, I decided to actually ask ChatGPT to solve this puzzle, to see how it performs.

It took some weeks to get to this stage, but here we are. It’s high time to ask this question:

There’s a riddle for you. It’s my birthday. My age is a number n with the property that the reverse of n shows up the earliest in the Collatz sequence of n. How old am I?

What do you think was the AI’s answer?

Well, the bot immediately replied with the confidence of an experienced con-artist:

You are 27 years old.

This is, of course, the wrong answer, so I asked ChatGPT to explain how it got the answer:

How did you reach this answer?

The Collatz conjecture, also known as the 3n + 1 conjecture, states that for any positive integer n, the following process will always eventually reach 1:

  • If n is even, divide it by 2.
  • If n is odd, multiply it by 3 and add 1.

The reverse of 27 is 72, and the earliest appearance of 72 in the Collatz sequence of 27 is at the third step:

27 -> 82 -> 41 -> 124 -> 62 -> 31 -> 94 -> 47 -> 142 -> 71 -> 214 -> 107 -> 322 -> 161 -> 484 -> 242 -> 121 -> 364 -> 182 -> 91 -> 274 -> 137 -> 412 -> 206 -> 103 -> 310 -> 155 -> 466 -> 233 -> 700 -> 350 -> 175 -> 526 -> 263 -> 790 -> 395 -> 1186 -> 593 -> 1780 -> 890 -> 445 -> 1336 -> 668 -> 334 -> 167 -> 502 -> 251 -> 754 -> 377 -> 1332 -> 666 -> 333 -> 1000 -> 500 -> 250 -> 250 ….

Therefore, the answer to the riddle is 27.

It correctly output the conjecture and it correctly printed a large set of numbers in the sequence starting at 27, knowing that is should be looking for 72. However, there is no 72 in the entire sequence and there is also a mistake after 377, the next number should have been 1132, not 1332. Still, it is quite impressive that it got this far. But, I am not 27, the answer to the puzzle is not 27, it does not even show up in the position the bot says it does. So, I point that out:

There is no 72 in the third step in the above sequence.

The bot tries again and fails:

I apologize for the mistake in my previous answer.

The correct answer to the riddle is then 36. The reverse of 36 is 63 and the earliest appearance of 63 in the Collatz sequence of 36 is at the third step:

36 -> 18 -> 9 -> 28 -> 14 -> 7 -> 22 -> 11 -> 34 -> 17 -> 52 -> 26 -> 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 -> 4 ….

Therefore, you are 36 years old.

This time, the entire sequence is correct, but there is no 63 in there. I point that out again, the bot replies that I must be \(2^{19} - 1 = 524288\) years old!

Seriously? Let’s just ignore that no human in history reached half a million years. How did it pick 19, why chose the power of 2, how did it not realize that the equation is off by 1?

Unfortunately, at this point the bot refused to give other attempts:

You are indeed not 36 years old. I’m sorry for giving incorrect answers in the previous attempts. Could you please provide more information or context to help me find the correct answer?

So I’m trying to give it a hint that my age cannot be greater than 100 and is definitely not less than 10.

If my age is xy, where x and y are digits, the number yx shows up the quickest in the Collatz sequence of xy. What is xy?

This time, the bot replies with

The answer to the riddle is 27.

When the input number n is 27, the Collatz sequence goes as follows:

27 -> 82 -> 41 -> 124 -> 62 -> 31 -> 94 -> 47 -> 142 -> 71 -> 214 -> 107 -> 322 -> 161 -> 484 -> 242 -> 121 -> 364 -> 182 -> 91 -> 274 -> 137 -> 412 -> 206 -> 103 -> 310 -> 155 -> 466 -> 233 -> 700 -> 350 -> 175 -> 526 -> 263 -> 790 -> 395 -> 1186 -> 593 -> 1780 -> 890 -> 445 -> 1336 -> 668 -> 334 -> 167 -> 502 -> 251 -> 754 -> 377 -> 1132 -> 566 -> 283 -> 850 -> 425 -> 1276 -> 638 -> 319 -> 958 -> 479 -> 1438 -> 719 -> 2158 -> 1079 -> 3238 -> 1619 -> 4858 -> 2429 -> 7288 -> 3644 -> 1822 -> 911 -> 2734 -> 1367 -> 4102 -> 2051 -> 6154 -> 3077 -> 9232 -> 4616 -> 2308 -> 1154 -> 577 -> 1732 -> 866 -> 433 -> 1300 -> 650 -> 325 -> 976 -> 488 -> 244 -> 122 -> 61 -> 184 -> 92 -> 46 -> 23 -> 70 -> 35 -> 106 -> 53 -> 160 -> 80 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1

We can see that the reverse of 27 (72) shows up in the third step of the Collatz sequence of 27.

While it still gives the first wrong answer of 27, at least this time it has no errors during the sequence of numbers. So, hoping to steer it on the right path, I ask it to go step by step:

Let’s go step by step. If a number n has 2 digits, x and y, what is the relationship between n, x and y?

The reply is good, including even an example:

If a number n has 2 digits, x and y, where n = 10x + y, then x and y represent the tens digit and the units digit of n, respectively. For example, if n = 36, then x = 3 and y = 6.

So, let’s move one step further:

If a number has 2 digits x and y, what is the number’s reverse?

The reverse of a 2-digit number n, with digits x and y, is a new 2-digit number obtained by swapping the positions of x and y. The reverse of n is equal to 10y + x. For example, the reverse of 36 is 63.

All good so far, let’s add the sequence process:

If a number has 2 digits x and y, what is the next number in the Collatz sequence in terms of x and y?

To which ChatGPT replies with:

Given a number n with 2 digits x and y, where n = 10x + y, the next number in the Collatz sequence can be calculated as follows:

  • If n is even, divide n by 2 to get the next number in the sequence.
  • If n is odd, multiply n by 3 and add 1 to get the next number in the sequence.

So, if n = 10x + y, the next number in the Collatz sequence, m, can be calculated as follows:

  • If n is even, m = n / 2 = (10x + y) / 2 = 5x + y / 2
  • If n is odd, m = 3n + 1 = 3(10x + y) + 1 = 30x + 3y + 1.

In both cases, m has 2 digits, with the tens digit equal to 5x + y / 2 (for even n) or 15x + 3y / 2 (for odd n), and the units digit equal to y / 2 (for even n) or (3y + 1) / 2 (for odd n).

So close… If only it would have stopped before the last phrase. There are articles which exploit the fact that after a \(3x+1\) step you get an even number so you can divide by 2 to shorten the sequence and it seems that that has confused our bot.

At this point, since the riddle’s answer is odd and its mirror is indeed the third number in the sequence, I ask ChatGPT to solve the corresponding math equation directly:

Solve 10y+x = 15x+(3y+1)/2

And… it fails, worse than a third grader:

Sure, let’s solve the equation 10y + x = 15x + (3y + 1) / 2:

10y + x = 15x + (3y + 1) / 2 10y + x = 15x + (3y + 1) / 2 10y + x = 15x + (3y + 1) / 2 10y - 15x = (3y + 1) / 2 - x 20y - 30x = 3y + 1 - 2x 20y - 30x = 3y - x + 1 19y - 29x = 3y - x + 1 19y - 29x = 3y - x + 1 19y - 29x = 3y - x + 1 19y - 30x + x = 3y + 1 19y = 3y + 30x - x + 1 16y = 30x + 1 y = (30x + 1) / 16

So, if the reverse of a 2-digit number n is equal to the next number in the Collatz sequence of n, then the units digit of n (y) must be equal to the tens digit of n (x) multiplied by 30 and added 1, all divided by 16.

Therefore, the only 2-digit number that satisfies this condition is 27.

Needless repetitions, forgetting terms, and then getting an answer which of course does not work.

I point out the mistake and ask for the equation to be solved

You have a mistake when you go from 20y - 30x = 3y + 1 - 2x to 20y - 30x = 3y - x + 1. After fixing the mistake, what is x and y?

The bot makes new mistakes, I correct them, repeating this in a loop for several cycles (which, in order to keep the article length under control, I’m skipping). In the end, ChatGPT reaches this


y = (28x + 1) / 17

So, if the reverse of a 2-digit number n is equal to the next number in the Collatz sequence of n, then the units digit of n (y) must be equal to the tens digit of n (x) multiplied by 28 and added 1, all divided by 17.

Therefore, the only 2-digit number that satisfies this property is 89.

The relationship is correct, but the solution is not. When pointed out, it tries again, rewriting the relationship and guessing wrong:


x = (17y - 1) / 28

So, if the reverse of a 2-digit number n is equal to the next number in the Collatz sequence of n, then the tens digit of n (x) must be equal to (17 times the units digit of n (y) - 1) divided by 28.

After checking all 2-digit numbers, it can be seen that only 47 satisfies this property.

After a few more iterations, it responds with

… The equation y = (28x + 1) / 17 with x = 3 and y = 7 verifies this property.

One digit right, but wrong for \(y\). So let’s ask it to compute:

What is (28 * 3+1) / 17?

(28 * 3 + 1) / 17 = 87 / 17 = 5.

This is correct, but then:

So why did you say that y=7?

I apologize for the mistake. I made an error in my previous answer. If x = 3, then y = (28 * 3 + 1) / 17 = 87 / 17 = 5.07, which is not an integer, so 3 and 7 do not satisfy the property.

I will continue to search for the correct solution.

It failed to do the division correctly, added a .07 and that made the answer wrong.

It turns out, once again, that the bot has issues with adding/subtracting 1:

What is 28 * 3+1?

28 * 3 + 1 = 87

Are you sure?

Yes, I’m sure. 28 * 3 + 1 = 87.

However, after a few more prompts, we get the right answer:

What is 28 * 3?

28 * 3 = 84.

What is 28 * 3+1?

28 * 3 + 1 = 87.

If 28 * 3=84 how can 28 * 3+1 be 87?

I apologize for the mistake. 28 * 3 = 84 and 28 * 3 + 1 = 84 + 1 = 85.

From this point, it seems it is finally able to solve the equation it last stopped at:

So if 28 * 3+1 = 85 then what is (28 * 3+1)/17?

(28 * 3 + 1) / 17 = 85 / 17 = 5.

So if x=3 what is y?

If x = 3, then y = (28 * 3 + 1) / 17 = 85 / 17 = 5.

So what is the number xy?

If x = 3 and y = 5, then the number xy is 35.

And, it finally manages to find out the answer to the puzzle:

So what is my age?

Based on the riddle, if the reverse of your age shows up the earliest in the Collatz sequence of your age, and x = 3 and y = 5, then your age is 35.

To be honest, given how long it took to reach this point (over 45 questions and answers; over 30 minutes of chatting), I was thinking that we are past that limit of tokens it could remember so it would not know anything about the riddle anymore. Happy to have been proven wrong here.

This article is already long, but there is a second part where we’re training the bot to actually write code to solve the puzzle. Does it get it? Tune in for next time.


Comments:

There are 0 comments (add more):