http://www.perlmonks.org?node_id=891806

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: 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
You can shave 3 off your lowest score using perl 5.10:
```# score = 53
#            1         2         3         4         5
#   12345678901234567890123456789012345678901234567890123456789
perl -E'say" "x(\$t-\$_),(1x\$_)**2for(1x(\$t=pop))**2=~/./g'          9
update due to hbm's observation:
```# score = 52
#            1         2         3         4         5
#   12345678901234567890123456789012345678901234567890123456789
perl -E'say\$"x(\$t-\$_),(1x\$_)**2for(1x(\$t=pop))**2=~/./g'          9
```perl -e 'printf"%*.0f\n",\$t+abs,(1x abs)**2for 1..(\$t=pop),1-\$t..-1' 9