Digital Haiku
I found this nice piece of code written by David (someone). Then I tried
to do one myself (my name is Stefan), but it was not that easy since I had one more letter
to squeeze out of the 32-bit integer (actually two letters since no letter
occured more than once) and I didn't want to do it the easy way as David
did it. It was fun to do and the result is beautiful but that rather depends
on how you define beautiful, doesn't it?
The task is simple. Write your name in an obscure way using ansi c.
The entire poem should be hard to understand, fit into 80 characters and
go against all good programming standards. The special digital haiku form
is the main->putchar->main - form which can be seen in the examples below
but there could be exceptions to this if it's beautiful enough.
Collection
DAVID (the original)
Author: David (someone, I have lost the name)
Description: The simplest of methods. Stores all the characters
in the integer (at least the 5 important bits of each character). This
method works for all names less than 7 characters long.
Characters stored: 'D' 'I' 'V' 'A' 'D' (five bits of each)
main(i){putchar(
340056100>> (i-1) * 5&31 | !!(i<6) <<6 ) && main(++i);}
STEFAN
Author: Stefan Hellkvist
Description: A more complicated way. Uses the fact that T is
S+1 and F is E+1 so a one is added to the previos character every second
character with the exception of the last character.
Characters stored: 'N' 'A' 'E' 'S' (all eight bits of each character)
main(i){putchar((1312900435>>((i-1)/2|i>5)*8)+!(1&i|i>4))^78&&main(++i);}
MAGNUS
Author: Magnus Ljung
Description: Uses the fact that some differences between characters
are 7.
Characters stored: 'S' 'G' 'A' 'M' (all eight bits)
main(i){putchar((1397178701>>(i/2+(i==3))*8)+(i/2==2)*7*(i-3))^83&&main(++i);}
STEFAN (yet another)
Author: Stefan Hellkvist (sort of)
Description: Same method as in David above
Characters stored: 'N' 'A' 'F' 'E' 'T' 'S' (Five bits of each)
main(i){putchar(471013011>>(i-1)*5&31|(i<7)<<6)&&main(++i);}
PER
Author: Stefan Hellkvist
Description: A simple second degree equation
Characters stored: None (sort of)
main(i){putchar(12*i*i-47*i+115)^82&&main(++i);}
EMIL
Author: Emil Brink
Description: A variant of same principle
Characters stored:
main(O){10<putchar(4^--O?77-(15&5128>>4*O):10)&&main(2+O);}
|