|There's more than one way to do things|
Diamonds for funby perl_nando (Novice)
|on Mar 05, 2011 at 10:53 UTC||Need Help??|
One geeky afternoon at work, we challenged each other to write the smallest possible program in any language to print a diamond made out of numbers, from 1 to a maximum of 9.
For example a diamond of 1 would just be 1.
A diamond of 2 would be:
A diamond of 3 would be:
And you get the idea for all the way up to 9...
One of them wrote several lines of c# code. Another wrote a really long one line of code that had predefined outputs. So I entered the prizeless contest, and I decided to use Perl.
I'm sure there is a way to make a long and ugly one liner out of this, but I wanted to share what I came up with after reading chapter 1 and 2 of Learning Perl.