Little Pony and Crystal Mine (Codeforces 454A)
Tags: Implement, implementation

Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n > 1) is an n × n matrix with a diamond inscribed into it.You are given an odd integer n. You need to draw a crystal of size n. The diamond cells of the matrix should be represented by character "D". All other cells of the matrix should be represented by character "*". Look at the examples to understand what you need to draw.

Input: The only line contains an integer n (3 ≤ n ≤ 101; n is odd). 

Output: Output a crystal of size n.


Sample Inputs:
3

5

7

Sample Outputs:
*D*
DDD
*D*

**D**
*DDD*
DDDDD
*DDD*
**D**

***D***
**DDD**
*DDDDD*
DDDDDDD
*DDDDD*
**DDD**
***D***

Solution (Python):
n = int(input())
for i in range(1, n, 2):
    a = int((n - i) / 2)
    print('*' * a + 'D' * i + '*' * a)
print('D' * n)
for i in range(n - 2, 0, -2):
    a = int((n - i) / 2)
    print('*' * a + 'D' * i + '*' * a)

Solution (Python):
n = int(input())
l = []
for i in range(n // 2):
    l.append('*' * (n // 2 - i) + 'D' * (1 + 2 * i) + '*' * (n // 2 - i))
l1 = list(reversed(l))
l2 = l + ['D' * n] + l1
for j in l2:
    print(j)

Solution (Python):
n = int(input())
for i in range(1, n // 2 + 2):
    t = 1 + 2 * (i - 1)
    print('*' * ((n - t) // 2) + 'D' * t + '*' * ((n - t) // 2))
b = []
for i in range(1, n // 2 + 1):
    t = 1 + 2 * (i - 1)
    b.append('*' * ((n - t) // 2) + 'D' * t + '*' * ((n - t) // 2))
for j in range(len(b) - 1, -1, -1):
    print(b[j])