Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Triangle Golf

by japhy (Canon)
on Apr 24, 2001 at 19:13 UTC ( #75085=note: print w/ replies, xml ) Need Help??


in reply to Triangle Golf

I offer, at 118 (not counting newlines):

@ARGV='ctriangle.txt';sub n{print " "x(40-$r/2).$x.$\};$/=$w;$_=<>; ($r=length($x.=" $_"))>$=and $==$r,n,$x=''for split;n


japhy -- Perl and Regex Hacker


Comment on Re: Triangle Golf
Download Code
Replies are listed 'Best First'.
Re: Re: Triangle Golf
by koolade (Pilgrim) on Apr 24, 2001 at 23:04 UTC

    The above didn't work for me. $\ is undefined by default so the newline doesn't print and $= is 60 by default so the tests fail. This is the best fix I could come up with, unfortunately with one extra character:

    @ARGV='ctriangle.txt';sub n{print " "x(40-$r/2)."$x\n"};$/=$w;$_=<>; ($r=length($x.=" $_"))>$/and $/=$r,n,$x=''for split;n;
      I'm sorry. I posted the code without testing it. I had meant $/ instead of $\, but I see that wouldn't have worked. Sorry about that.

      japhy -- Perl and Regex Hacker

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2015-07-30 21:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls