28
2
I figured an "arch" was the best way to describe this pattern of numbers:
1234567887654321
1234567 7654321
123456 654321
12345 54321
1234 4321
123 321
12 21
1 1
Formally defined, each line consists of the numbers 1 through 9-n
, (n-1)*2
spaces, and the numbers 9-n
through 1 (where n
is the current line).
Your task is to write, using the shortest code possible, a small script/program that prints the above pattern subject to the following restrictions:
- You may not hardcode the entire pattern. You may only hardcode a single line of the pattern at most.
- Your program must print a newline (any combination of
\n
or\r
) at the end of each line.
Ready... set.... go!
1Additional little trick would be available with upper line
123456787654321
as it equals to11111111^2
;-) – Egor Skriptunoff – 2013-05-12T13:57:27.5033@EgorSkriptunoff
11111111^2 == 123465787654321 != 1234567887654321
(notice the repeated8
) – Bob – 2013-05-12T14:43:02.320This is sort-of the inverse of Print this diamond
– Peter Taylor – 2013-05-14T09:23:21.0636
It looks rather like a curtain.
– Volatility – 2013-05-15T08:53:06.783