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

updated version of old sig

by teamster_jr (Curate)
on Oct 22, 2003 at 12:07 UTC ( #301203=obfuscated: print w/replies, xml ) Need Help??

UPDATE: I've done it!!!! 4 lines:
@m=((31,(15)x8)x8,(31)x9);$m[$c]|=16,!(@a=grep/-?./&!(16+$|*$'&$m[$c+$ +&] ),-18,11,94,-92)?$c=pop@p:${$_=$a[rand@a];s/-?.//;push@p,$c;$m[$c]&=~( +8/ $_);++$u-64?$m[$c+=$&]&=~$_:map$_&=15,@m,$c=$|=1},$|&&9x3e7,print"\ec" +, map$_%9?($_-$c?$m[$_]&2?_:$":o).($m[$_]&8?"|":_):$/,1..72until$c>70&$|
It uses a horrible horrible hack for the select (9x3e7 which takes ~10 ms on my machine, but YMMV, if it works at all... (you can increase the e7 to slow down, lower it to speed up)

also still needs vt100 (for \ec). and yes, had to make some allowances to get it into 4 lines... ho hum.

the original post is in the readmore:

so i've been trying to compress these obfus for ages into a single 4 line sig. unfortunately i can only just get it shorter than 5 lines.

so here's the best i can do (including suggestions from people here), as ever it requires VT100.

@m=((31,(15)x15)x10,(31)x16);$m[$c]|=16,!(@a=grep!($m[$c+$$_[0]]&16+$s +*$ $_[1]),[-1,8],[1,1],[16,4],[-16,2])?$c=pop@p:${($i,$j)=@{$a[rand@a]};$ +m[ $c]&=~8/$j;push@p,$c;$m[$c+=$i]&=~$j;++$u-150||map$_&=15,@m,$c=$s=1}, +$s &&select$x,$x,$x,.1*print"\ec",(_)x31,map$_%16?($_-$c?$m[$_]&2?_:$":o) +.( $m[$_]&8?"|":_):"$/|",0..160until$c>158&$s
if anyone can golf it down to 4 lines (of 72 chars - i need to lose 42 chars) i'd be
  • surprised :-)

  • eternally grateful

it's all explained here:
it basically does 2 passes using depth first search:
#set up maze - only border visited @m=((31,(15)x15)x10,(31)x16); # until loop starts now #say we've visited current square $m[$c]|=16, #find possibilities (on 1st pass ($s=0) just check visited # on second pass also check the bit is unset for that direction # 4 #8 1 # 2 !(@a=grep !($m[$c+$$_[0]]&16+$s*$$_[1]), [-1,8],[1,1],[16,4],[-16,2] )? # if one isn't found then go back $c=pop@p: # if one is found, then pick it and unset the bits (ie allow access th +rough) ${ ($i,$j)=@{$a[rand@a]}; $m[$c]&=~8/$j; push@p,$c; $m[$c+=$i]&=~$j; # and finish if we visit them all (unset visited bit in @m) ++$u-150||map$_&=15,@m,$c=$s=1 } # and draw (space is here for formatting in wrapped version) $s&& select$x,$x,$x,.1*print"\ec", (_)x31, map$_%16?($_-$c?$m[$_]&2?_:$":o).($m[$_]&8?"|":_):"$/|",0..160 # and redo unless it's the end until$c>158&$s

Love Handles & fistycuffs
EDIT: clarified the 4 line limit!
2nd update: golfed it down to 5 lines!
And again: - thanks to people's suggestions (especially mtve & benizi) it's now down to 41 chars over the 4 line limit.....

and again: I found a bug in the original code which i've fixed.

Replies are listed 'Best First'.
Re: updated version of old sig
by jonadab (Parson) on Oct 22, 2003 at 15:33 UTC

    Here you go, four lines:


    Very nice obfu, BTW. ++

    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
      LOL! - see updated post!

        Well, I thought about compressing it and bundling the results with a decompressor and eval, but the only type of compression I'm very familiar with is Huffman, and even after I renamed some variables and things to cut down on the number of distinct characters, the character set is still too broad for the size of the program, and so by the time I have to use only six of every eight bits to ensure that all the characters are printable, I can't get compression good enough to make room for the decompressor and tree, much less come out seventy-some keystrokes shorter.

        $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
Re: updated version of old sig
by nimdokk (Vicar) on Oct 22, 2003 at 12:34 UTC
    Pretty nifty, even on my Windows machine :-)

    "Ex libris un peut de tout"
Re: updated version of old sig
by benizi (Hermit) on Oct 24, 2003 at 20:53 UTC

    I know it's really minor, but every stroke counts:

    You have several ternary ops using '==' (e.g. $_==16?$p:$_&=15). Since the variables're all integers, you can accomplish the same thing using '-' and reversing the order of the options. (e.g. $_-16?$_:$p&=15).

    In general X==Y?A:B is equivalent to X-Y?B:A. (Note that, in the more complicated (multiple-)ternaries, you'll have to do a bit more shuffling.)

    Also, I thought I should tell you that your latest version (4 lines + 70) doesn't work properly on my machine:
    (This is perl, v5.8.0 built for i686-linux)
    It gets to the upper left corner, the entire grid changes to squares, and it continues to wander.

    Update: Or at least that's what it did when I forgot to edit out the other <code> sections... (oops)

      Few more minor suggestions

      @m=((16,(15)x15)x10,(16)x16);$m[$c]|=16,!(@a=grep!($m[$c+$$_[$l=0]]&16 ++$ s*$$_[1]),[-1,8],[1,1],[-16,2],[16,4])?$c=pop@p:${($i,$j)=@{$a[rand@a] +}; push@p,$c;$m[$c]&=~(8/$j);$m[$c+=$i]&=~$j;++$v-150||map$_-16?$_:$p&=15 +,@ m,$c=$s=1},$s&&select$q,$q,$q,.1*print"\ec",'_'x31,map$l++%16?($l-1-$c +?$ _&2?_:$":o).($_&8?'|':_):"$/|",@m[0..160]until$c>158&$s
Re: updated version of old sig
by Skylark (Beadle) on Feb 23, 2004 at 20:06 UTC
    Sure, not really hard to do, but here is the same version as at the top of the page, updated to work on Win32: (change system('cls') for whatever other clearscreen you have on your system if you don't have a VT100 compatible terminal...)
    @m=((31,(15)x8)x8,(31)x9);$m[$c]|=16,!(@a=grep/-?./&!(16+$|*$'&$m[$c+$ +&] ),-18,11,94,-92)?$c=pop@p:${$_=$a[rand@a];s/-?.//;push@p,$c;$m[$c]&=~8 +/$ _;++$u-64?$m[$c+=$&]&=~$_:map$_&=15,@m,$c=$|=1},$|&&9x9999999,system(' +cls'),print"", map$_%9?($_-$c?$m[$_]&2?_:$":o).($m[$_]&8?"|":_):$/,1..72until$c>70&$|
    Removes 2 chars to add 13. Enjoy


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://301203]
Front-paged by broquaint
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2017-05-22 18:13 GMT
Find Nodes?
    Voting Booth?