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

Re: ASCII Pattern - Golf (Russ: 83)

by Russ (Deacon)
on Sep 19, 2003 at 02:39 UTC ( #292565=note: print w/replies, xml ) Need Help??


in reply to ASCII Pattern - Golf

I can get 83:
$i=9;do{print((map{(sort map{abs}$_-$ARGV[0],$i-$ARGV[1])[-1]}1..9),"\ +n")}while--$i

Russ

Replies are listed 'Best First'.
Re: Re: ASCII Pattern - Golf (Russ: 77)
by Russ (Deacon) on Sep 19, 2003 at 02:57 UTC
    Okay, now 77 (if you don't miss the trailing newline):
    $i=9;do{print"\n",map{(sort abs$_-$ARGV[0],abs$i-$ARGV[1])[-1]}1..9}wh +ile--$i

    Russ

      74 :)
      $i=9;do{print$/,map{(sort abs$_-$ARGV[0],abs$i-$ARGV[1])[1]}1..9}while +--$i

        A for-loop is usually shorter than a do{...}while-loop. 70 :-)

        $t=abs$ARGV[1]+$_,print$/,map{(sort$t,abs$ARGV[0]-$_)[1]}1..9for-9..-1

        If you want the newlines "right", I end up at 72:

        $t=abs$ARGV[1]+$_,print map((sort$t,abs$ARGV[0]-$_)[1],1..9),$/for-9..-1

        Update: Well, what do you know ... the string $ARGV[1]+$_ is longer than the strings ($s=pop) and $s taken together. Make those 69 and 71 (both with tie-breaker at 30 different characters):

        $t=abs,print$/,map+(sort$t,abs$ARGV[0]-$_)[1],1..9for($s=pop)-9..$s-1

        ... and ...

        $t=abs,print map((sort$t,abs$ARGV[0]-$_)[1],1..9),$/for($s=pop)-9..$s-1

        The Sidhekin
        print "Just another Perl ${\(trickster and hacker)},"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2022-05-22 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (80 votes). Check out past polls.

    Notices?