# Diamond with numbers [duplicate]

Inspired by this, print an ascii diamond pattern built using 0-9.

Rules

• Input n should be between 0-9, anything outside that range is undefined
• The diamond should be padded with spaces
• The middle line should always have no padding and be the only line to contain n, in the center
• Print to stdout
• As always, this is

Test Cases

• n = 0
0

• n = 1, print
 0
010
0

• n = 2, print
  0
010
01210
010
0

• n = 9, print
         0
010
01210
0123210
012343210
01234543210
0123456543210
012345676543210
01234567876543210
0123456789876543210
01234567876543210
012345676543210
0123456543210
01234543210
012343210
0123210
01210
010
0

• Unfortunately, someone already had the same challenge idea. – xnor Jul 8 '16 at 4:54
• @xnor Wait - I don't think it's a duplicate. That asked you to print that specific diamond -- it was a k-complexity question. The answers will vary because this is asking you to generate it. – Insane Jul 8 '16 at 4:58
• I'm not sold that the input makes a big difference, but I'll retract my dupehammer and let people vote. In particular, it seems to me like a lot of the answers could change their parameter 9 to an input. – xnor Jul 8 '16 at 5:03
• I also feel like this is a duplicate, in the sense that answerers here could, in many cases, reasonably just look at the previous challenge’s solutions and replace a 9 by an input() or something. – Lynn Jul 8 '16 at 5:06
• Starting from 0 might make a difference in messing up the arithmetic trick that 1111*1111=1234321, though I think that's unfortunate because it's a cool strategy. Is there something new that's allowed by the zeroes? – xnor Jul 8 '16 at 5:08

# Vitsy, 50 bytes

I don't think I'm done golfing yet!

VVHr1mV{V2*1+\[2m]
:Xru
v&VvD([D\[' 'O]]-H1ml\NaOY


Explanation:

VVHr1mV{V2*1+\[2m]
V                  Pop n, set n as the global final variable (GFV).
V                 Push the GFV to the current stack.
H                Pop n, pop o, push each item of the range from o to n.
r               Reverse the current program stack.
1m             Call the method on line index 1.
V{           Push the GFV to the bottom of the current stack.
V2*1+      Push the GFV*2+1 to the stack.
\[  ] Pop n, do the stuff in brackets n times.
2m  Call the method on line index 2. Note that this is necessary due
to an unknown bug.

:Xru
:                  Clone the current stack, pushing a second stack to the stack
stack and jumping to it.
X                 Pop n and discard.
r                Reverse the current stack.
u               Pop the current stack and concatenate it to the previous.

v&VvD([D\[' 'O]]-H1ml\NaOY
v                  Pop n, save as a temporary variable.
&                 Push a new stack to the stack stack and jump to it.
V                Push the GFV.
v               Push the temp var, clear the temp var memory.
D([        ]   If the top item is not zero, do the stuff in brackets.
This is necessary as all loops always apply once.
D\[' 'O]    Peek n, output n spaces.
-               Pop n, pop o, push o-n.
H              Pop n, pop o, push each item of the range from o to n.
1m            Call the method at line index 1.
l\N         Output all numbers in this stack.
aO       Output a newline.
Y      Pop and discard the current stack from the stack stack.


Try it online!

• That was SpOOky as hell I didn't realize you deleted it – Insane Jul 8 '16 at 5:41
• @Insane Yeah, I made a one byte error. :P Fixed now. – Addison Crump Jul 8 '16 at 5:42
• @Insane Explanation added. – Addison Crump Jul 8 '16 at 5:55
• – Addison Crump Jul 8 '16 at 6:06