Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Diamonds for fun

by BrowserUk (Pope)
on Mar 05, 2011 at 11:10 UTC ( #891562=note: print w/ replies, xml ) Need Help??


in reply to Diamonds for fun

Golf:68. How to get rid of those reverses?

perl -E"$n=pop;say' 'x($n-$_),1..$_,reverse 1..$_-1for 1..$n,reverse 1 +..$n-1" 9

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: Diamonds for fun
Download Code
Re^2: Diamonds for fun
by a (Friar) on Mar 06, 2011 at 00:15 UTC
    Had to:
    perl -e '$n=pop; print "\n", " "x($n-$_),1..$_,reverse 1..$_-1, for 1. +.$n,reverse 1..$n-1' 9
    for 5.8 ish ... seems like there's a marvelous recursive solution but my brain is too small to find it.

    a

Re^2: Diamonds for fun
by LanX (Canon) on May 04, 2011 at 16:22 UTC
    Golf:56 :)
    perl -E'$_=pop;sub r{1..$_,reverse 1..$_-1}say" "x(9-$_),r for r' 9 1 121 12321 1234321 123454321 12345654321 1234567654321 123456787654321 12345678987654321 123456787654321 1234567654321 12345654321 123454321 1234321 12321 121 1

    Cheers Rolf

      Combining with other posts here, golf:55

      perl -E'$_=pop;sub r{1..$_,reverse 1..$_-1}say$"x(9-$_),r for r' 9

      Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2015-07-04 21:41 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 (60 votes), past polls