Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Obfuscated code

( #1597=superdoc: print w/ replies, xml ) Need Help??

Got some code which would take a Perl grand master to understand without running it? Post it in this section so we can stare at it in awe.

Word of warning, though: Don't be too cocky with your post — almost inevitably someone will post a reply that does the exact same thing in even fewer characters!

New Less than Readable Code
Is it possible to shorten this code?
2 direct replies — Read more / Contribute
by uacnix
on Jun 16, 2015 at 13:18

    Hello dearest Monks,

    i'm looking for the wisdom of shorthening my code:
    use LWP::Simple; @a = <>; getprint("".($a[0])."&b=".($a[2]));
    As You have noticed, i'm not interested in the second line, but it is required that the program takes 3 lines of input:

    -a digit

    -some bollox that You can skip in the program execution, but it will have to bypass/workaround/skip this line

    -some more or less random characters, that have to be passed as argument.

    I'm just a peasant in PERL, but I heard it's the best language to write shortest code, so i'm trying my luck with It.

    Thank You in advance guys.


    -I've checked the codes, and I've been able to use only the choroba's first code and at this place I'm really sorry that I didn't mention the STDIN input and chomp.

    I found a workaround for chomp- I do it "serverside", my script on the site checks for newline symbols and replaces them

    Anyway, thanks to You, dear Monks, my code is 14 chars shorter, and that's great progress, thank You!
Optimized Mandelbrot set generator
1 direct reply — Read more / Contribute
by thisisdada
on Jun 14, 2015 at 18:30

    I wrote a Mandelbrot set generator. It works on Windows ActivePerl 5.20.2 x64, but I haven't tried it on *nix. It outputs a smoothed, anti-aliased fractal image to 24-bit .bmp file. For optimizations, it takes advantage of symmetry; it skips the cardoid, the main bulb, and the line across y=0; and it checks for cycles when the iteration count gets high. On my computer (2.40GHz i5-2430M), it takes about 10 minutes to generate a 1500x1000 image.

    The code's designed to look like the set, of course. It takes user input to determine the size of the image and the outfile, i.e.:

    C:\Users\Kevin> 1200 mandel.bmp Generating fractal with dimensions 1200 by 800... [==================================================] Saving fractal to mandel.bmp... Done!

    If the given pixel width isn't divisible by 12, the program subtracts until it is.

    for$b(-25..25){for$a(-50..29){$x=$a/21;$y=$b/15;print$b?chr:chr^chr ord(substr'<6C}'.1x29 .'[FDEq2?@E96Cqa6C=q924',$a)-49;$_=30;($y,$x) =(2*$x*$y+$b/15,$x*$x-$y*$y+$a/21)while$x*$x+$y*$y<9&$_++<95}$_=10}
Convoluted Echo
2 direct replies — Read more / Contribute
by KurtSchwind
on May 22, 2015 at 14:19

    So let's say you are on a *nix machine and you need an application that echos what you type. And let's further say that you want to use perl, python, ruby and shell to do it. I bring you convoluted echo. A perl script the writes and executes a python script that's and executes a ruby script which writes and executes a shell script to echo your command line arguments.

    Happy Memorial Day

    #!/usr/bin/perl my $echo = q{}; open my $py, '>', '' or die "Cannot open $!\n"; $py->print("#!/usr/bin/python\n\n"); $py->print("import os\n\n"); $py->print("fo = open(\"ce.rb\",\"w\")\n\n"); $py->print("fo.write(\"#!/usr/bin/ruby\\n\")\n"); $py->print("fo.write(\"out_file =\\\"\\\", \\\"w\\\ +")\\n\")\n"); $py->print(q{fo.write("out_file.puts(\"#!/bin/sh\\n\\necho $*\\n\\ +")\n")}); $py->print("\n"); $py->print(q{fo.write("out_file.close\n\n")}); $py->print("\n"); $py->print("\n"); foreach my $a (@ARGV) { $echo .= " ".$a; # $py->print( " $a "); } $py->print(q{fo.write("system(\"/bin/sh }); $py->print(" $echo "); $py->print(q{\")\n")}); $py->print("\nfo.close()\n"); $py->print("os.system(\"/usr/bin/ruby ce.rb\")\n"); close $py; system("/usr/bin/python");
    “For the Present is the point at which time touches eternity.” - CS Lewis
Polybius JAPH
1 direct reply — Read more / Contribute
by teamster_jr
on Apr 29, 2015 at 11:36
    $_ =q#( $.=" 20 2c4a 506 175" )=~s {[ \W] ?([ \w] )\s ?(\w ) }{ $ |= 1 ; "0x$ 1$2 ".( 5 - (++$ b)? " ," :".. " ) }xeg ;$ l=~ s { \s}{ ; ""}exg;@t=split //, "\44_ =q\43$_\43; s/\134\156//xg; eval ".($"x2)."\43TSR'15";map{ $ a[$c /5] [$c++%5] =chr } eval $ .; do {$s += 1; my $ z; if ($t [$s ] eq $"){($ d++% 2 ?$x: $ y )=$ s- $e;$e= $s+ 1;if( !($ d-2) ){$ d=0; push @j,$ a[$ x ][$ y] } } }while@j-25; print join $ /, unpack ("( A69)*" , join"" ,@ t ), join "",$ /, (m ap{( "\43", @$_,$ /) }@ a),"\n\43 ",@j,$/;#; s/\n//xg; eval #TSR'15
JAPH does the splits
1 direct reply — Read more / Contribute
by Schmunzie
on Apr 12, 2015 at 19:14
    My first JAPH for years and years. I'm not sure if this is platform-independent. I hope it is.
    @z=split(//,BGu6pCozwKzR);@y=qw(zlz hqa zuo reg rqz fpx 72 26 25 53 25 + 06);while(@z){@a=split(shift@z,crypt(shift@y,pop@y));@g=split(pop@z, +$a[1]);print $g[0]}
This One's a Sieve
3 direct replies — Read more / Contribute
by Schmunzie
on Mar 31, 2015 at 11:17
    hdb recently pointed out that I had misremembered how the Sieve of Eratosthenes works so now I'm having another go. Not all that obfu'd but moderately golfed.


What Perl Will Tell
No replies — Read more | Post response
by martin
on Mar 20, 2015 at 00:05
    This one may be somewhat system-dependent but worked with quite different flavours of Perl. I expect it will be difficult to predict without actually using a perl binary. Have fun!
    eval'[]->Jk',$^X=~m;(?:.*[\\/])?([^\W\d]+);;$==ord('?'^':'),$,=q** ,*_=[map+chr,$[..$=<<$=],*_={map{;$_,++$=}grep/(?=\W)[$"-~]/,@_},* _=sub{map{join$,,@_[@_{split$,,$_}]}+$,."->]'","!?;'(&}","(! .\\}" },*_=[_(split$,,$@),"\u$1"],*_=\"@_[$[,!!!$[,-!$[,$#_^!$[],",print
Are old obfus gone forever?
5 direct replies — Read more / Contribute
by Schmunzie
on Mar 19, 2015 at 20:39
    Years ago, with a previous account (no idea of my name then) I posted an obfu of which I was immensely proud. The code was in the shape of an ornate grand-father clock, complete with pendulum and the output was the current time (to the nearest 12 mins) on an ASCII analogue clock face.

    I would love to see it again.

Not a Sieve
2 direct replies — Read more / Contribute
by Schmunzie
on Mar 16, 2015 at 06:51
    $i++;while(@p<50){$i++;&d;print"$i,"x!$x}sub d{for(@p){if($x=(!($i%$_))){return}}push@p,$i}
An obfu for Pi Day
No replies — Read more | Post response
by Schmunzie
on Mar 14, 2015 at 09:24
    $e=$k=$f=$a=$m=$n=1;@y=split//,"mpqeyn";$y=$p=$a+$m+$n;push@mn,pop@y;u +nshift@mn,shift@y;while($#p<14){$a++;@b=@p;&d}while($f>2**-$p[$#p]){$ +i+=2;$r=$i%4;$f=4/($i*($i+1)*($i+2));$p+=$f*($r-1);if($i/2<$p[$p[4]]) +{eval"\$$mn[$r/2]+=\$$mn[!$r]";$y=$y/2+1/$y;eval"\$q=\$$mn[$r/2]/\$$m +n[!$r]";$k*=($i/2);$e+=1/$k}}for$o(@y){print"<br>$$o"}sub d{while(@b) +{$x=!($a%shift@b);if($x){return}}push@p,$a;print"$a,"}

Set the new obfuscation standard
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (11)
    As of 2015-06-30 09:34 GMT
    Find Nodes?
      Voting Booth?

      What kind of chocolate gives you the most pleasure?

      Results (780 votes), past polls