Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

SHORTER Useless code

by arhuman (Vicar)
on Mar 13, 2001 at 03:10 UTC ( [id://64013]=note: print w/replies, xml ) Need Help??


in reply to Useless .... of course !

It's been a game between Gloom and me, but may be you may like it too !

So, If you're interested in Perl golf, come on and join the contest...
Let's turn this 'useless code' into 'shortest useless code'
(RULE: Reproduce the spiral made by gloom with the fewest char.
the screen cleaning, shebang and the like aren't necessary...)

Here is my contribution (84 char):
$n=20;$i=1;while($n){map{print"\e[$a;${b}H@";${$n>$_?*b:*a}+=$i}1..2*( +$n-=2);$i*=-1}


PS: For a really impressive PerlGolf example see this.


"Trying to be a SMART lamer" (thanx to Merlyn ;-)

Replies are listed 'Best First'.
Re: SHORTER Useless code
by BooK (Curate) on Mar 14, 2001 at 16:14 UTC

    I am sorry to disappoint you, arhuman, but the following is not shorter (94 bytes, darn scalar)... But well, it's recursive... and just another way to do it.

    <code> sub _{($x,$_)=@_;s/(.*)\n/\n $1@/g;$x>40?x:_($x+2,scalar reverse'@'x$x."\n$_\n".$"x$x)}_;print <code>

    Change the 40 for smaller or bigger spirals...

      Interesting !

      the recursive branch is now open..


      "Trying to be a SMART lamer" (thanx to Merlyn ;-)
Re: SHORTER Useless code
by Gloom (Monk) on Mar 13, 2001 at 19:35 UTC
    82 ! switching from while to for and saving 2 characters :
    for($n=20,$i=1;$n;$i*=-1){map{print"\e[$a;${b}H@";${$n>$_?*b:*a}+=$i}1 +..2*($n-=2)}

    __________________
    Hope this helps
Re: SHORTER Useless code
by bobione (Pilgrim) on Mar 13, 2001 at 14:46 UTC

    Good Job arhuman,
    I don't know if I can write a smaller one but I'm sure it's possible.

    Let's try !

    BoBiOne

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-29 05:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found