Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: ASCII Pattern - Golf

by glwtta (Hermit)
on Sep 19, 2003 at 02:13 UTC ( [id://292559]=note: print w/replies, xml ) Need Help??


in reply to ASCII Pattern - Golf

well, this looks like right output:

($a,$b)=@ARGV;for($y=9;$y>0;$y--){$c=abs$b-$y;print$/,map{$d=abs$a-$_;$c>$d?$c:$d}(1..9)}

without cheating it's a few characters longer.

Replies are listed 'Best First'.
Re: ASCII Pattern - Golf
by cLive ;-) (Prior) on Sep 19, 2003 at 02:38 UTC
    Let's knock another 4 characters off :)
    ($a,$b)=@ARGV;for($y=9;$y--;){$c=abs$b-$y;print$/,map{$d=abs$a-$_;$c>$ +d?$c:$d}(1..9)}

    .02

    cLive ;-)

Re: Re: ASCII Pattern - Golf
by devslashneil (Friar) on Sep 19, 2003 at 02:31 UTC
    Ahh i really like that one, i was thinking of doing it a similar way but i couldn't get it producing the right output, i also thought of using sort($a-$_,$b-$y)[0]; to get the greatest but couldn't get that working.

    Neil Archibald
    - /dev/IT -

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-26 01:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found