Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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 ;-)


Comment on SHORTER Useless code
Download Code
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

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 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 ;-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (20)
As of 2014-04-23 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (541 votes), past polls