Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Guess what it does ... and a challenge

by liverpole (Monsignor)
on May 24, 2008 at 17:42 UTC ( #688317=obfuscated: print w/ replies, xml ) Need Help??

First, can you guess what the following code does before running it? ...
1x~@;

This node by shmem gave me the idea, and may give you a hint as well.

Now for the challenge ... what's the shortest program which does the same thing?  My guess is the obvious:

How about the smallest program that does the same thing slowly?  The following takes about 11 seconds on my laptop:

I have no idea if a shorter such program exists.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Comment on Guess what it does ... and a challenge
Select or Download Code
Re: Guess what it does ... and a challenge
by blokhead (Monsignor) on May 24, 2008 at 19:36 UTC
    I parsed that code correctly in my head, but didn't realize what the result would be.

    Here is a program of the same length (as your second snippet) that does the same thing slowly:

    blokhead

        No, it won't. Now, if you do $_='a' first, then it will, and extremely slowly too.

        - tye        

Re: Guess what it does ... and a challenge
by kyle (Abbot) on May 24, 2008 at 20:04 UTC
Re: Guess what it does ... and a challenge
by shmem (Canon) on May 24, 2008 at 22:53 UTC
    First, can you guess what the following code does before running it?

    Oh yes...

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: Guess what it does ... and a challenge
by ambrus (Abbot) on May 25, 2008 at 11:40 UTC
Re: Guess what it does ... and a challenge
by ambrus (Abbot) on May 25, 2008 at 11:54 UTC
golf! (now this title is more than one word)
by mtve (Chaplain) on May 31, 2008 at 18:59 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-10-21 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (95 votes), past polls