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

Re: bigger japh

by ambrus (Abbot)
on Jul 27, 2006 at 01:41 UTC ( #563935=note: print w/replies, xml ) Need Help??

in reply to bigger japh

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.

Replies are listed 'Best First'.
Re^2: bigger japh
by SubStack (Monk) on Jul 27, 2006 at 14:45 UTC
    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


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://563935]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2016-10-25 10:24 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (316 votes). Check out past polls.