This Is The Coolest Thing You Can Get A Computer To Do In 10 Lines Of Code

code 2

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.

Credits: Imgur

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.

Keith Winstein and Marc Horowitz from MIT have written a seven-liner Perl code called Qrpff. The function of the program is to descramble a DRMprotected DVD, in real time. The program has become a symbol of the anti-DRM movement, given its size, which is small enough to be printed on T-shirts and included in Email Signatures. 

“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.

2.Whatsapp Hack

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.

Credits: Quora

The output as seen by her friends is shown here:

Credits: Quora
Honorary Mentions

Before we announce our top pick, here are some honorary mentions;

Algorithmic Symphonies

The explanation of the programs that produce music as output can be found here.

3D Modelling

Here is an OpenSCAD code of 20 lines, by Steve Caplin.

Credits: Quora

The output is a 3D model of a sphere trapped inside a cube, as shown below.

Credits: Quora
 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.

Here is the JS1k 2010 – 750 – playable version of the code implemented in javascript within 1kb



Leave a Reply

Your email address will not be published. Required fields are marked *