100, 10, 1
Your friend, Cole, shows you his first attempt at programming: a calculator that takes in a binary sequence and does an arbitrary computation on it:
- If the binary sequence ends with a
0, delete it. - Otherwise, add a
0to the end, add the original sequence to it, then add 1 to it.
You test it with a random sequence of 0s and 1s: 11010 and press “Calculate”.
As expected by the first rule, it takes off the 0 at the end to give 1101.
Lazy to enter another binary sequence, you press “Calculate” again with 1101 now being the input. As expected by the second rule, it adds a 0 at the back (giving 11010), adds 1101 to the sequence (giving 100111), and finally adding 1 to it to give you 101000.
It looks like it works, so you press “Calculate” repeatedly. The digits flash by:
10100
1010
101
10000
1000
100
10
1
100
10
1
100
10
1
100
10
1
It looks like it’s just repeating the sequences 100, 10, and 1 in a loop.
“Huh, I’ve never tested my program like this before,” Cole says. “What do you think if we started with a different binary sequence?”
This time, you start with the binary sequence 11110001.
11110001
1011010100
101101010
10110101
1000100000
100010000
10001000
1000100
100010
10001
110100
11010
1101
101000
10100
1010
101
10000
1000
100
10
1
100
10
1
100
10
1
100
10
1
The process takes longer this time, but sure enough, it eventually ends up at the pattern 100, 10, 1 too.
“Hmm, is it a coincidence?” Cole asks.
“I’m not sure,” you reply. “But we can test it out.”
You spend the afternoon trying out different numbers, eventually ending up with the 100, 10, 1 sequences each time.
“I think that no matter what binary sequence you start with, you always add up at 100, 10, 1,” Cole declares.
What do you think?
Hint
At the time of writing this puzzle, nobody knows the solution to this.
Hint
The binary sequence is a red herring. Try converting the computation to decimal numbers.
Hint
Consider these 2 questions:
- What’s a special property of numbers whose binary representation ends with a
0? How about1? - What happens to a number if we add
0to the end of its binary representation? How about if we removed a0from the end?
Obvious Hint
Look up the Collatz Conjecture.
Solution
Before we dive into the “solution” (or lack thereof), let’s take a look at the binary representation of a number. Imagine we have a number n with a binary representation of:
n=...b4b3b2b1b0
This gives rise to a value of:
n=...+(24b4)+(23b3)+(22b2)+(21b1)+(20b0)
Notice how that apart from the b0 term, everything else is a multiple of 2? This means that n is even if and only if b0 is 0, and odd if and only if b1 is 1. Let’s call this Lemma 1.
Let’s define a number n′ such that its binary representation is given as:
n′=...b4b3b2b1b00
Where bk are the digits from our original n. Then n′ would be:
n′=...+(25b4)+(24b3)+(23b2)+(22b1)+(21b0)+(0)=2×(...+(24b4)+(23b3)+(22b2)+(21b1)+(20b0))=2nIn short, adding 0 to end of a binary representation of a number will double it. Let’s call this Lemma 2.
By the same logic, if a number’s binary sequence ends with a 0 (meaning it is an even number), then removing the 0 from the end will divide the number by 2. Let’s call this Lemma 3.
Let’s take a look at the rules of Cole’s program again:
- If the binary sequence ends with a
0, delete it. - Otherwise, add a
0to the end, add the original sequence to it, then add 1 to it.
Taking what we have just learnt, we know that the machine takes in a number n, then outputs:
- 2n if n is even (by Lemma 1 and Lemma 3).
- 2n+n+1 if n is odd (by Lemma 1 and Lemma 2).
Simplifying the second rule, we get:
- If a number is even, divide it by 2.
- If a number is odd, multiply it by 3, then add 1.
We’ve arrived at the Collatz Conjecture.
Consider the function f:
Then the Collatz Conjecture states that regardless of which integer n you begin at, applying the function f repeatedly to it will eventually result in reaching the number 1.
Applying f repeatedly to 1 will result in the sequence 1→4→2→1 repeating, which is the 100, 10, 1 sequence we’ve seen in our earlier examples. Cole’s hypothesis and the Collatz Conjecture are equivalent.
However, the Collatz Conjecture, at this time of writing, has not yet been solved. If either Cole’s hypothesis or the Collatz Conjecture is proven or disproven, then the other one is automatically proven or disproven too. Until then, we’ve got some ways to go.
Try These Next
9 Dots
You have 9 dots arranged in a 3×3 grid: Without lifting your pen, draw four straight lines that pass through all 9 dots.
Antipodal Temperature and Pressure
Assume the earth is a perfect sphere. Show that at any given time, there exist two antipodal points (points on exact opposite sides of the Earth) with the same...
Stack of Coins 1B
You and your friend stumble on another pirate’s treasure: 99 copper coins and 1 gold coin. As before, these old coins are no longer legal tender, so the copper...