Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

SHORTER Useless code

by arhuman (Vicar)
on Mar 13, 2001 at 03:10 UTC ( #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 !


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://64013]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2017-04-29 00:15 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.