Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Better random magic

by BenGoldberg (Sexton)
on Dec 29, 2013 at 20:11 UTC ( #1068701=obfuscated: print w/replies, xml ) Need Help??

Although the text of the japh is plainly readable in the code, what exactly happens to the split up letters that are passed to _ and __ is... a secret!

sub r{srand$^T; @_}sub b{do{@b=map.5<rand,@_}until grep($_,@b)&&grep( !$_,@b);@b}sub _{print(@_),return if@_<2;my(@L,@R);push@{$_?\@L:\@R}, shift for&b;_(@L);_(@R)};sub __{1<@_ or return@_;my@b=&b;my$c=grep$_, @b;my@L=__(@_[0..$c-1]);my@R=__(@_[$c..$#_]);map shift@{$_?\@L:\@R}, @b}_ r __ r split//,"Just Another Perl Hacker,\n";

If you aren't confused yet, run the code in a debugger, and note the list that __ returns, then try to figure out how _ magically prints the letters in the correct order.

Also... I'm fairly sure that this code (unlike my previous randomized JAPH) should be run ok on any perl, even though I've only tested it on 5.12.1

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://1068701]
Approved by tobyink
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2018-05-22 20:15 GMT
Find Nodes?
    Voting Booth?