Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

bigger japh

by SubStack (Monk)
on Jul 24, 2006 at 16:23 UTC ( [id://563309]=obfuscated: print w/replies, xml ) Need Help??

This one recreates a 613 byte ascii-artish japh with 448 bytes of code and data.
$_="b4lb13ib24ib3lab4lblb3lb2gfebfdf2b5gf2iblgfgb2gfgb2fdf2blf2gbgf2gb +igf2eab4lblb3lb2jb4lb8k2lblb2lblb3lb2lb3lb2lblk2iblabib2lblb3lb3jb3lb +7lb2lblb2lblb3lb2lb3lb2lblb4labck2cb2jkhb2jkhb3ckhb5ck2lblb2lb2jkhb3c +khblb2lbck2ebla2b17clb7lb14labigf2gbgf2gbigf2eblb7lf2gbgf2ib2gfgblb2g +bgf2gbigf2eablb3lblk2iblb5lb7lb2lb2k2lblb2cblkhb2lk2iblabljkgcbck2ebl +b4glgb6lb2lbck2lbck2eblbjb2ck2eblb2fgablb53hablb53a"; s/(\D)(\d+)/$1x$2/eg&y!a-z!\n '+-/:\\_|!&&print

Replies are listed 'Best First'.
Re: bigger japh
by ambrus (Abbot) on Jul 27, 2006 at 01:41 UTC

    Nice. I tried LZ77 compression (see LZ77 compression, a poem) on the output of this japh as well to see how short I can make it. I've got this.

    $_=v10.10;{$_.=substr($_,3135-&j-94*&j,&j-33).chr&j;redo} sub j{<<'!'=~/./g||exit!print;ord$&} #!! "!" $!"|&!% &!& 1!#:/!. :!/|R!(|X!'.b!!-c!!,b!"-f!!+&!"-b!&.)!#:m! +#. 4!".9!%.z!#-:!%|>!#.;!%.y!#.I!#,`!/\A"._"!"|N"%|~!)|(!( c""_<!":="%:=" +, ]!%||"(|V"(|\!3 x"''~!#'3"$_V#!/&!& [##''!& :!%|0"(\:!*|y#%'S"#,U#"|)$ +' )$-':", B$,|e"$.T#/ e"*-l#':#$'|B$$ {#-|]$'_N#% =%-|H%&_"$''p#$/Y%$_u# +'| 5##.;##'k"& *%%|$%$ D$)'W$%'>!'\N#&,5&%-]%!.1"' 2&9 K&9/Z!X S'" !
    It is only a few characters longer than your original code.
      Very cool. Here's the script I used to generate the constant for the japh, although it's not too much more clear than the japh itself.
      #!/usr/bin/perl my $file = <STDIN>; my %chars; $chars{$_}++ for split //, $file; my @set = sort { ord $a <=> ord $b } keys %chars; my $set = quotemeta join "", @set; $file =~ eval "\$file =~ tr($set)(a-z)"; $file =~ s/($_{2,})/$_ . length $1/eg for "a".."z"; print "set=$set (@{[map ord, @set]})\n$file";
      Basically, each of the characters used in the japh (pipes and dots and slashes and such) is translated to a letter. Next, for every string of duplicate characters is shortened to the letter and the number of characters it should be expanded to, so "aaaaaa" becomes "a6". There's probably an official name for this technique someplace.

        There's probably an official name for this technique someplace.

        Run Length Encoding

        ---
        $world=~s/war/peace/g

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-07-21 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.