Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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!

Replies are listed 'Best First'.
(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?
[Dumu]: got it. Anyway. Perl question. Can you use binmode more than once with an open filehandle to read a file first in binary mode, then in utf8 mode?
[ambrus]: Dumu: you can use binmode multiple times, but mostly at the start before you read things. it would be strange to change the io layers after you've already read things, and might not work too well.
[ambrus]: Dumu: why would you want to read the same file both in binary mode and utf8 mode?
[Corion]: Dumu: Yes, but switching needs to be done with caution, as you might read half an UTF-8 character in binary mode, and then switch to utf8 mode...
[Corion]: Personally, I would do the decoding of data in the program and not in the filehandle
[Corion]: ambrus: Maybe a record-based file where some data is strings encoded as utf8
[Corion]: But again, I would read all data as binary and then decode from utf8
[ambrus]: Corion: that wouldn't be my guess, but I'll wait for Dumu
[Corion]: Meh. I'm now on Firefox 57 ("Quantum") and again have to remove Pocket, and reinstall the adblocker, uMatrix (because NoScript doesn't work) and silence the about:blank page to not download crap from the internet
[Corion]: Maybe I shouldn't update software ...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2017-11-20 17:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (290 votes). Check out past polls.

    Notices?