in reply to Diamonds for fun
I'm quite sure this can be golfed further, but as it seems shorter than the above solutions I must post it.
perl -le 'printf"%*s\n",$t+$_,(1x$_)**2for(1x($t=pop))**2=~/./g' 9
Update: see also Christmas Tree.
Update: one character shorter:
perl -e 'printf"%*s\n",$t+$_,(1x$_)**2for(1x($t=pop))**2=~/./g' 9
Somewhat shorter:
perl -le 'print" "x($t-$_),(1x$_)**2for(1x($t=pop))**2=~/./g' 9
Update 2012-03-14: and see Spiraling integers for yet another arrangement of numbers.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Diamonds for fun
by toolic (Bishop) on Mar 07, 2011 at 14:45 UTC | |
Re^2: Diamonds for fun
by hbm (Hermit) on Mar 07, 2011 at 20:38 UTC | |
by ambrus (Abbot) on Mar 07, 2011 at 21:14 UTC |