Mirrored Number Triangle

Given a positive integer n, return a mirrored number triangle with n rows and total width 2n. Row i prints 1 through i, then 2(n-i) spaces, then i down…

Given a positive integer n, return a mirrored number triangle with n rows and total width 2n. Row i prints 1 through i, then 2(n-i) spaces, then i down through 1. Preserve interior spaces, add no trailing spaces or trailing newline, and join rows with one newline.

- 1 ≤ n ≤ 9 - n is always a positive integer. - Every number is one decimal digit.

Example 1: input n = 4; output 1 1 12 21 123 321 12344321. The center gap shrinks by two while both mirrored prefixes grow by one digit.

Example 2: input n = 1; output 11. The center gap is empty, so the two copies of 1 meet.

Category: Pattern Programs. Topic: pattern-programs. Difficulty: Easy. Patterns: math.