I entered the following program in the 5th annual Obfuscated Perl Contest, where it won second prize:
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{ @p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f|ord ($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&& close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
Well, not quite. I wrote the program long before the contest, and then kept it secret for a long time. Then when the contest rules were finally published, my hopes were dashed! The rules specified a limit of 256 characters, and my program, as you see, had been carefully formatted to fit into four lines of 77 characters each, in the style of a usenet signature. The program totaled 312 characters, which was 56 too many. So the program I actually submitted was a shortened version that is not as much fun.
I think Felix made a bad judgement, because the winning program was not nearly as confusing as mine---it was actually very simple. If you fixed the indentation, it was quite straightforward. My program is impossible to understand even if you fix it up with good formatting and reasonable variable names. In the solution file I provided, I expanded it in this way, and it still took me about 2500 words to explain what was going on.
To appreciate this program properly, you really have to run it. Please do that. It will flip you out. You can download the source code if you want to. (The actual contest entry is also available, but I think it is less interesting.)
If you think you understand how this works, ask yourself the following quiz question:
What is
@P
for? Why does it have the value".URRUU\c8R"
?
If you think you understand this program, but you can't explain
@P
, then you are mistaken, because @P
is the
central data structure of the entire program.
Here are the hints that I provided to the contest judges. If you think you've figured out the answer, look at the hints one at a time before you get to the solution. I guarantee that there will be something that you misunderstood.
Hint 1 | Hint 2 | Hint 3 | Hint 4 | Hint 5 | Hint 6 | Hint 7 | Hint 8 | Hint 9 | Hint 10 | Hint 11
I will reveal the solution on December 1, 2000.
Return to: Universe of Discourse main page | What's new page | Perl Paraphernalia
mjd-perl-obfuscated-id-i1s+bw5g9s9+@plover.com
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.