As a Brain teazers lover, code sometimes can be a fun toy for me. From last year, I started to play around with python challenge occasionally and reached level 13 (with cheating). The famous python challenge seems quite difficult for me. Because the answers are easily to be found online, I could not help looking for hints when I felt I was stuck. Recently I came across a similar web puzzle provided by Chen Hao on coolshell (He is an influential programmer), the puzzle was release last Saturday, fresh new. It is quite concise that do not require too much time to solve. Yet it is informative and very smart! I went through the puzzle by coding for every required steps. Later I realized there are actually plenty of resources available, as long as you know what you are looking for. Google/Wikipedia solves problem better than my code. But I am glad that I tried, with great effort and really learned something as concrete knowledge rather than information that can only be considered to be known to me. Here I note down the process.
Level 0 Brainfuck
With the first sight, I did feel that my brain had been fucked. What the hell was that? Hopelessly I googled the only words on the page, and surprisingly found that there is a programming language called brainfuck. The language consists of only eight simple commands and an instruction pointer. It is designed for fun. The operators > < + - . , [ ] are corresponded to some operations on a pointer. Interpreted it using a piece of python code.
Compile the c code and run, I got the answer
welcome.html for next level
Level 1 Answer to Life
There are two numbers to be figured out. One is from the series 2, 3 ,6, 18, 108. It is obvious that the next number is always the product of the previous two numbers. Therefore one of the number is 18 * 108 = 1944. The other number is the “answer” to the ultimate question of life, the universe and everything, 42. Finally got 1944 * 42 = 81648, which led me to the next level.
Level 2 Keyboard
There is a strange keyboard and a string below. It was easy to come up with the idea that the string is the output from this strange keyboard, which corresponds to the one from a normal keyboard. So I manually built up the corresponds between the letters from these two keyboard and encode the string.
It looks life c code, so I saved it as c program, compile and run.
Later I knew that this keyboard layout is called Dvorak Simplified Keyboard. There is a type of encoding based on the differences in layout of a QWERTY keyboard and a Dvorak keyboard. The piece of the key.c code is famous. This program won a “Best One Line Program” award in 1987. But I could not quite understand it - yes, it is exactly that my code runs, and I don’t know why
unix to enter the next level.
Level 3 QR Code
There is a QR code, scan to get encoding information like
Decoding the line of letters below:
Decode the information, we are told:
“Where there is a shell, there is a way. I expect you use the shell command to solve this problem, now, please try using the rot13 of “shell” to enter next level.”
Use ROT13 to encode “shell”to get “furyy”. ROT13 cipher is to replace a letter with the one 13 letters after it in the alphabet. The interesting property is that encode and decode is using the same algorithms for ROT13. So encode “furyy” again, we get back to “shell”.
furyy to get to the next level.
Level 4 Cat
The idea is similar to a level in Python Challenge, so I quickly got started. One of the tricks is that the hints are in the html source code. However I was also constrained by the idea of solving that similar Python Challenge problem and stuck in this problem for a very long time! Finally I got the correct idea, which is to match the pattern using Regular Expression.
Previously I did not use regular expression (coz I really didn’t know about regular expression!) I searched through all the text for 5-letter arrays and checked its pattern manually. I then went through one chapter talking about regular expression in the book The Linux Command Line, an excellent book I am reading for month, talking about fundamentals on Linux command line and shell. Here () is used to define a marked subexpression, later can be recalled for matching. That is how the RE checks the equality between the leading and ending letters, and between the second and the second last letters.
Using shell command
The answer is the center letters in the Palindromes:
Level 5 Keep Going
This is very similar to one of the puzzles in Python Challenge. The hint is found by clicking the image. A number shows - 32722. Replace the number 2014 in the url with this number, a new page was shown with a new number. Keeping doing this led me to the answer!
At last I got
Level 6 Binary Tree
This is a test on the classic binary tree algorithms - Binary tree reconstruction from in-order traversal and post-order traversal. The main idea is to use the information that the last node in the post-order array is the root of the tree. That root value can be found in the in-order array which divides the array into two, each indicates the left branch and right branch from that root. By counting the number of nodes in each branch, the post-order can also be divided into two branches, which corresponds to the ones in the in-order array. In this case, in-order and post-order array for the left and right sub-trees are found and the problem can be solved recursively.
Use the string found from the longest path of the binary tree to decode the information given, I got a word
Level 7 NQueens
A classic algorithm question again. Nqueens problem is to place n queens on an n by n chessboard, where solutions exist for all natural numbers n with the exception of n = 2 and n = 3. NQueens problem is a good example for backtracking algorithm practice. The java code to solve 9 queens problem:
There are totally 352 solutions, traverse all to find the one whose sha hash equals to the given encoded information
Found the answer
Level 8 Excel Number
It is easy to notice that this is a base26 to decimal conversion. Using the code below:
The output is
Level 9 Pigpen
Finally got to the last level! There seemed to be no relations between the given two images. Looking around for a while and with some useless search, the hints showed up when I googled one of the pictures - pigpen. There is a cipher, called pigpen or Freemason’s cipher, which is a geometric simple substitution cipher which exchanges letters for symbols. The graphs below can be easily decoded as helloworld using the diagram below
Get to the page using
helloworld. Finally get to the end. It is really an incredible journey to work through all the problems. Along the way I learned a lot funny topics and fundamental knowledge about computer science which I lack of. Most of the problems can be easily solved by searching online, but I coded from sketch as a coding practice. I feel lucky and grateful that I stepped into this wonderful world 4 year ago, although it’s a bit late. I would choose to stay in this field for my career.
Wait! I was told it is not the end! Here is hidden information. View the html source at the helloworld page, I can find a line below the shutdown image
“Did you even think vi an image file?”
Interesting! Well, let’s vi the image file. Save the shutdown.png and open it with vi. There is a line
“This Image actually is a RAR file as well.”
Save it as an rar file and unzip
Here we get a text file helloworld.txt, open it. There are some information about hello world program, c language, and the father of c programming language - Dennis Ritchie. The keyword to next level:
In Memoriam - Dennis Ritchie Hello world, the world full of imagination, creativity and joy, that brought to us by those great scientists.