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

Useless .... of course !

by Gloom (Monk)
on Mar 09, 2001 at 03:05 UTC ( [id://63125]=obfuscated: print w/replies, xml ) Need Help??

Ok, this is no realy a japh but I doubt you can do shorter and more useless ! I'm joking dude ... I know you can't :)

#!/usr/bin/perl -w use strict; #require "vt100 complilant terminal :)"; print "\033[2J"; # really start here for( my($a,$x,$y,@s)=qw(40 1 0 0 1 0 -1);$a--;push@s,shift@s) { print "\033[",$x+=$s[0] ,";",$y+=$s[1] ,"H\@" for (0..$a) }

_________________________
Perl Enshrine Real Life

Replies are listed 'Best First'.
SHORTER Useless code
by arhuman (Vicar) on Mar 13, 2001 at 03:10 UTC
    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 ;-)

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

      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: Useless .... of course !
by arhuman (Vicar) on Mar 13, 2001 at 19:54 UTC
    81! You had a good idea Gloom, I just enhanced it...
    :-p
    for($n=36,$i=1;$n-=4;$i*=-1){map{print"\e[$a;${b}H@";${$n/2>$_?*b:*a}+ +=$i}1..$n}

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2024-04-23 21:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found