Several Ways to Congratulate a Programmer

Posted by Mariia Mykhailova on October 20, 2011

I want to carry on a tradition I started a year ago with this post, and tell about several more ways to make your "Happy Programmer's Day!" greetings look both unusual and professional at the same time. This time I'll be printing simply "congrats" - all simple ways have already been covered last year.

I know this post is a month late, but my studies, travels and studies again prevented me from publishing it earlier.

Method #1. Magical

This nomination traditionally shows professional tricks in common everyday languages, in this case C++.

#include <stdio.h>
int main()
{   int A = 10, B = A^1937006968, C = B^337251857;
    printf((char *)&C);
}

Disclaimer. This trick is based on low-level memory manipulations; the results may vary depending on the computer's architecture and the compiler used.

I've explored this method in my earlier post Numerical Signatures (with a Bit of Magic). Long story short, it is based on creating numbers which contain the bytes of the required string, and printing them as strings. For better obfuscation one can represent these numbers as a result of some operations on other numbers - this way none of them will look like messages in other view modes.

Method #2. Cloak-and-dagger

Last year this nomination featured Whitespace, which is an evident choice when it comes down to writing something invisible, but by far not the only one. This time I'll use Ruby to get almost the same effect.

print "
                                                                                                  
                                                                                                              
                                                                                                             
                                                                                                      
                                                                                                                 
                                                                                                
                                                                                                                   
                                                                                                                  
            
          
".map{|z| z.size.chr}

Of course it's not so impressive; the commands which frame this ocean of whitespace mar most of the impression. But the program itself is much easier to develop: each string within the quotation marks is transformed into one character with ASCII-code equal to the length of the string. The contents of the strings is completely irrelevant; for example, one can put there some explicit text or ASCII-art like this:

print "
                                                                                                  
                                                                                                              
 ##  ##   ####   #####   #####    ####   ##  ##   ####   #####   #####                                       
 ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##                               
 ######  ######  #####   #####   ######  ######  ######  #####   #####                                           
 ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##                         
 ##  ##  ##  ##  #####   ##  ##  ##  ##  ##  ##  ##  ##  #####   ##  ##                                            
                                                                                                                  
            
          
".map{|z| z.size.chr}

Method #3. Dramatic

This is not really a standalone method, but rather a bugfix for a last year's method. I finally managed to run the Shakespeare interpreter, and I'm ashamed to tell that last year's message was totally wrong - it didn't even get interpreted. First of all, the language recognizes only Shakespeare characters known to the interpreter's author: no Ariel, no Prospero and no Caliban for me. Same goes for the vocabulary: no guinea pigs and drunken idiots, only the vocabulary approved by the author (and a pretty scanty one, I must say). Finally, the adjectives must match the noun's emotional coloring. Following all these rules imposes a lot of constraints, and robs the text of most of its charm.

Method #4. Classic

Last year I was too harsh to Befunge - it's a great language to create disguised messages, as long as you're ready to put some creativity into this. For example, a message can look like this:

v  >  AA  vBBB  >RRR   AA  v  >  AA  vBBB  >:#,   _ @ I
"  " A  A "   B "   R A  A "  " A  A "   B "   R  I I I
SHHT AAAA ABBB  RRRR  AAAA GHHN AAAA OBBB  CRRR   I I I 
"  " A  A "   B " R   A  A "  " A  A "   B " R   
>  ^ A  A >BBB  ^  RR A  A >  ^ A  A >BBB  ^  RR  o o o

If you have a closer look at the encryption, you'll notice that the characters v, > and ^ direct the instruction pointer along some lines. Between the pointer's turns you can see the commands which push the characters on the stack - they look like "quotes - character - quotes", since in Befunge double quotes switch interpretation mode to string mode and vice versa. "Extra" characters met by the instruction pointer are simply ignored. The program ends in the top right corner of the image with a loop which prints the characters from the stack in reverse order (last in - first out).

Method #5. Ornamental

Here I present you a program in Piet - this language gives you more chance to be creative than the last year's Brainloller.

ASCII-codes of the letters are encoded in blocks sizes, and the colors set the order of actions "push previous block's size on the stack - print the topmost element of the stack as a character - repeat".

Enjoy! And I'll see you again next year, hopefully closer to the programmer's day itself.

Freelance Jobs

blog comments powered by Disqus