Disclaimer: No animals, especially unicorns and dragons were harmed during the code-writing practices shown below.
The general belief among masses is that programming is a very hard thing to learn or do. Once you have learned it, even to perform simplest of tasks, you need to write lengthy lines of code, and even the simplest mistake like using a comma instead of a semi-colon will not allow the program to be compiled and eventually function. Well, I would love to tell you it’s just a scary rumor, it is not.
Despite the carefulness and present-mindedness coding requires, there are some simple and fun things you can do using programming in different languages and here are a few examples.
5. Tomohiko Sakamoto’s Algorithm
The Sakamoto Algorithm is used when you have a date from past or future and you need to know what day of the week falls on that date. The code was published by Tomohiko Sakamoto, in 1992, on the comp.lang.c Usenet newsgroup. The Tomohiko version calculates the day of the week accurately for Gregorian calendars. The simple following code can be studied in depth here.
4. Fork Bomb
Otherwise known as rabbit virus or wabbit, the Fork bomb is essentially an infinite loop. The program generates a process that replicates itself continuously resulting in the occupation of available resources. This will slow your system down and eventually, due to resource starvation, will crash it. When the resources will be consumed by the processes generated by the Fork bomb only, it will serve as a denial of service attack for other processes.
The simple line of codes grows exponentially until it takes over entire CPU time and the process table of the operating table. More on Bash code for Fork bomb can be found here.
3. Descrambler, Qrpff.
Qrpff. The function of the program is to descramble a –protectedand Marc Horowitz from MIT have written a seven-liner Perl code called
“I think there’s some value in demonstrating how simple these things really are and how preposterous it is to try to restrict their distribution.” Winstein said.
Being a coder, you can prank your friends and have some fun with them as well, here is Shruti Shamdasani’s Selenium spam. Using the simple code shown below, she was able to prank some her friends.
The output as seen by her friends is shown here:
Before we announce our top pick, here are some honorary mentions;
The explanation of the programs that produce music as output can be found here.
Here is an OpenSCAD code of 20 lines, by Steve Caplin.
The output is a 3D model of a sphere trapped inside a cube, as shown below.
1. Toledo Nanochess
The Toledo Nanochess, developed by Mexican Oscar Toledo Gutiérrez, is a chess engine. Not just any chess engine, Toledo Nanochess, a five-time winner of IOCCC, International Obfuscated C Code Contest. The rules of the contest are to use a max 1255 character long code. Oscar claims it is the smallest chess C program of the world.