Here is the entry that I sent into the
TPJ 5th annual obfuscated Perl contest. I entered it in as a diversion. The code is actually a team effort, I wrote the core and then
Tye and
I set to work obfuscating and souring (removing the sugar from) the code. And yes, it is 'strict' and does not generate warnings when used correctly. It can also take user input on the command line.
($@,$?)=(@ARGV,9,9);$:=1-$?*$@;print"# ",'##'x($@-2),"# #
";$_[0][$_]=$_[$?+1][$_]=8for 0..$@;$_[$_][0]=$_[$_][$@+1]=8for
0..$?;$/=1+rand$?,$.=1+rand$@;@@=[$.,$/];$_[$/][$.]=$^=4;while($:)
{$"=$^-->3?rand 4:++$"%4;1>$"?$.--:2>$"?$/--:2^$"?++$/:$.++;if($_[$/][
$.]&&1){pop@@,$^=4if!$^;($.,$/)=@{$@[-1]};next}$_[$/][$.]=$^=4;$"<
2?$_[$/][$.]|=1<<$":($_[$@[-1][1]][$@[-1][0]]|=1<<$"-2);push@@
,[$.,$/];++$:}print"#",map({$_%2?' ':' #'}@$_[1..$@]),"
#",map({2&$_?' #':'##'}@$_[1..$@]),"\n"for@_[1..$?]
Disclaimer: The contest required the code to work under Perl 5.6, some things in this code might not work on older versions of Perl. (Although I think it will work with versions 5.005 and newer)
Update: Nov 2, 2000
Well, the results are in over at TPJ, and we didn't win. We didn't even place.
Oh well, there is always next year!
In reply to OneWay
by Adam
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.