A friend of mine just sent me a brain teaser. It looked so intriguing, all those numbers ordered in some kind of fashion. So i decided to take on the challenge. This is what Sebastiaan sent:
Taking on the challenge
My first attempt was performed in Textedit, and it was a cumbersome process of shuffling and reshuffling numbers. My guess was that R was a negative number, and with some negative trickery the puzzle was solvable.
After a few minutes of failed attempts I recognized my brain failed at this hour. So lets do some stupid programming, in order to figure out the correct values for the puzzle.
Firing up a text editor and writing out the formula, i hunched at the formula’s tightness. If the formula is not written correctly, the puzzle is incorrect and thus unsolvable. If not, the numbers will probably even out in a few iterations. The challenge then is to find an iteration that matches the start value: Z = 1.
Finding initial values
The formula did balance out. Only with some initial values set to 8 or higher, the result would crash. With the following initial values, i found the simplest outcome of this puzzle:
$K = -1; $L = -1; $R = 2; $W = -1; $Y = 1; $Z = 1; iteration 0 Y + R = K | 1 + 2 = 3 K + R = L | 3 + 2 = 5 R + R = W | 3 + 2 = 4 Y - R = Z | 1 - 2 = -1 K - W = Z | 3 - 4 = -1 L - W = Y | 5 - 4 = 1 R * R - W = R | 2 * 2 - 4 = 0 iteration 1 Y + R = K | 1 + 0 = 1 K + R = L | 1 + 0 = 1 R + R = W | 1 + 0 = 0 Y - R = Z | 1 - 0 = 1 K - W = Z | 1 - 0 = 1 L - W = Y | 1 - 0 = 1 R * R - W = R | 0 * 0 - 0 = 0 K = 1 L = 1 R = 0 W = 0 Y = 1 Z = 1
I also found one other answer after a few other input combinations. How many more could there be?
Taking it one step further
That wasn’t too hard, just some guessing, and it was fixed. All iterations after iteration 1 resulted in the same answer: Z is 1 and manually checking this sum confirmed correctness. Now, what other answers could there be. I expanded the sourcecode of the original puzzle to try all input variables from -9 to 9. That would be 18 * 18 * 18 * 18 * 18 * 18 * 18 attempts, or 18 ^ 6 or 3401224 attempts to solve this puzzle.
I was wondering how many solutions there would be, and how many input variables resulted to the same solution. Couldn’t be that hard. With little rewriting and some debugging we came to the following code:
The final answer
For humans, trying any value below -9 or higher than 9 would mean intense complexity. So after performing all 34 million possibilities with some iterative logic, the chance of someone guessing the right answer is pretty high:
Array ( [notfound] => 33487344 [126.96.36.199.4.1] => 314928 [188.8.131.52.1.1] => 209952 )
Using floating points resulted in nothing new. Unfortunately, i’d hoped for some cool answers that did not involve integers. Well, at least we’ve tried. The cool thing with floats is that the answers keep on fluctuating; it never evens out. Well, i tried with 10.000.000 iterations, and still different things happen.
The following morning: Hey just wait a minute… Only R and Y make sense in this equation. Thats why most of the time nothing happened. Lets try it with only modifying R and Y… nothing 🙁
My initial assumption was wrong: there is no answer that uses negative integers in the range of -1 to -9. It just doesn’t exist. Excel couldn’t make heads or tails of the data, it was simply too large for a graph. I’m thinking of datawhorehouse tooling. Trying with fewer parameters and only 0.1 and etc didn’t result in any answer. Well, enough for now, i could stretch this to the end of the galaxy. All files are available for download.
That concludes this nights brainteaser, its time for slee… zzzzzzz
- Attached file: midnight_brainteaser