High and Low Complexity

"This image illustrates part of the Mandelbrot set fractal. Simply storing the 24-bit color of each pixel in this image would require 1.62 million bits, but a small computer program can reproduce these 1.62 million bits using the definition of the Mandelbrot set and the coordinates of the corners of the image. Thus, the Kolmogorov complexity of the raw file encoding this bitmap is much less than 1.62 million bits in any pragmatic model of computation." —Wikipedia

Most programming languages are relatively easy to read, such as a C#, or Javascript. However, not all languages are designed to be this Human-Readable. Such languages (Such as Jelly, Pyth, GolfCode, etc.) at first glance look like someone generated a random string of characters, such as this Pyth code:
WtQ=Q@,/Q2h*3QQQ
(Returns all Collatz Sequence numbers starting at Q)

However, programs written with these are rarely very long. This is certainly not by chance. Instead, these languages are designed for Code Golfing, a recreational competition to see who can write a program to get the desired output with the lowest Kolmogorov complexity. (No, that's not a Scifi show alien or something; it's the length of the program.)
Let's dissect and examine this Pyth code:
FNrZhTN 
First, the F at the start. This simply says "Start a For loop". Then make a Variable N. Set this F loop's range from Z to T, zero to ten. the "h" says include the ten in the range. Then print N.
It outputs: 0 1 2 3 4 5 6 7 8 9 10

Want to play with Pyth yourself? Here's online interpreter: http://pyth.herokuapp.com/ 

Enjoyed this article? Tell me at @Cyborus.

Thank you to @Cyborus for writing this insightful article! It is out first guest-written post. If you would like to be a guest writer, please contact Stang. 

4 comments

4 comments :

Post a Comment

Please be appropriate and respectful.