The fun(?) side of programming

Programming is often regarded as a very complex, hence very serious, task by non-programmers. Is that true? In most cases, that is the fact. A programmers always have to dealing face-to-face with many problems. Handling never ending requirement, creating an algorithm to solve problem, fixing little bugs that hidden inside the programs, maintaining old programs, keeping up to date with new technology, and the list is still long. There is no room for a little fun right?

Or not.

There is a lot of fun in programming. The joy of programming is to solve a problems or challenges. Yes, the word fun in programming is closely related to challenge. No challenge means no fun at all. For this particular reason, there are so many website that offer many problems to solve by curious and determined programmers.

Many type of challenge is unique and creative. The theme usually simple but to solve it one will need a good understanding in programming concept and programming language features. Are you ready to take the challenge? Below is a list of some creative challenge you can try🙂.

Create programs with minimum amount of code

The most notable contest with this theme is Perl Golf Apocalypse (PGA) and JS1K. PGA  is perl coding competition with the objective of solving a basic programming task with the smallest perl code possible. In JS1K, a programmer can submit JavaScript code that complete any task, with size less than one kilobyte.

To complete this kind of challenge, one must have a deep understanding of the feature of programming language and use the most simple method to solve the problem. Create a chess with AI with a code less than one kilobyte is not an easy task, even for experienced programmer.

There is also a challenge to create the shortest hello world program possible. The winner so far is Jon Skeet. He even create a brand new programming language with purpose solely to print hello world. He only need one character to print it. “Arguably I could have designed it to only accept an empty file as input, but that would have been silly (source)” he says. He even have his own Jon Skeet Facts.

Create a very long and complex program to complete very simple task

How hard is to build a program that print “Hello World” to screen? A very simple task. Hello world program is the first program created for most of programmers. This program can be completed in less than five minute, even if you are just start learning your very first programming language.

Some people in stackoverflow.com give you a challenge to code a hello world program as palindrome. It’s mean your code can be read the same way in either direction. It is no easy task for a programmers. Another person ask for the longest hello world program. Try to read the code below, in chimpanzee voice :

#example that prints Hello World!
Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook! Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook! Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook.
Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook.
Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook.
Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook!
Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook! Ook. 

That is a hello world program written in Ook programming language. It’s real and it’s works perfectly. In case you want to know, there are 282 Ook words written in that code. Another notable submission is code in Chef and Shakespeare programming language.

In perl community exist Just Another Perl Hacker (JAPH) challenge. Perl programmer is compete to create most creative way to create program that print “Just another Perl hacker,” in their signature. The code then embedded in their signature. You can see the example in JAPH Wikipedia page. Make sure you see the camel one😉.

Obfuscated Code Contest

A good code is a code that easy to read and easy to understand. But there are some situation when you want to protect your code by making it hard to read. This kind of code is called obfuscated code. Something like this :

char*M,A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf(M="%d",&C);
--            E;             J[              E]             =T
[E   ]=  E)   printf("._");  for(;(A-=Z=!Z)  ||  (printf("\n|"
)    ,   A    =              39              ,C             --
)    ;   Z    ||    printf   (M   ))M[Z]=Z[A-(E   =A[J-Z])&&!C
&    A   ==             T[                                  A]
|6<<27<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];}

If any lecturer ask the students the output of that program, I’m quite sure all the students will fail.

By the way, there are three obfuscated code contest : International Obfuscated C Code Contest, Obfuscated Perl Contest, and International Obfuscated Ruby Code Contest. Below is the goal of International Obfuscated C Code Contest :

  • To write the most Obscure/Obfuscated C program under the rules below.
  • To show the importance of programming style, in an ironic way.
  • To stress C compilers with unusual code.
  • To illustrate some of the subtleties of the C language.
  • To provide a safe forum for poor C code.🙂

This is one of the submission. The program is used to calculate the value of pi:

#define _ -F<00||--F-OO--;
int F=00,OO=00;main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
{
            _-_-_-_
       _-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_
        _-_-_-_-_-_-_-_
            _-_-_-_
}

Another submission can be seen in ioccc website.

That’s it. A programmer is able to having fun too, but in different and challenging way. I’m quite sure many other creative challenge exist. If you know any, you can tell us in your comment. Thank you and have fun in code🙂.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s