Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

OneWay

by Adam (Vicar)
on Aug 23, 2000 at 02:11 UTC ( #29124=obfuscated: print w/ replies, xml ) Need Help??

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!

Comment on OneWay
Download Code
(bbq) RE: OneWay
by BBQ (Deacon) on Sep 01, 2000 at 20:44 UTC
    Very cool! Worked nicely on my machine...
    version 5.005_03 built for i586-linux

    #!/home/bbq/bin/perl
    # Trust no1!
RE: OneWay
by Rydor (Scribe) on Sep 03, 2000 at 04:52 UTC
    Cool, but one problem.... The solution to the maze 9 out of 10 times is just go down, over to the right, and right back up. it generally ignores the lower part of the maze.

    @:::::::((==========Rydor====>
      That's the problem with taking a fully solveable - randomly generated maze and then sticking the entrances that close together. In order to stay with-in the char count for TPJ, I was forced to drop the random entrance code. You can, of course, pick any starting and ending points you want. You can also generate larger mazes (reducing the likely-hood of an overly simplistic one) by running the script with your desired dimensions on the command line.

      OneWay.pl 39 20

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://29124]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2014-09-19 14:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (140 votes), past polls