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.
Examples
Input
3
Output
D
DDD
D
Input
5
Output
DDDD
DDDDD
DDDD
Input
7
Output
DDDDDDDDD
DDDDDDD
DDDDDDDDD
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
We need to generate a pattern: an n x n matrix (n odd). There's a diamond shape inscribed: cells where the Manhattan distance from the center? Actually let's analyze patterns.
For n=3:
Rows (0-indexed maybe):
Row0: * D *
Row1: D D D
Row2: * D *
So diamond covers positions: center (row1,col1) and its four orthogonal neighbors? That's a plus shape, but it's a diamond? Actually a diamond in a square matrix is typically defined by condition: |row - center| + |col - center| <= radius? For n=3, radius = (n-1)/2 = 1. Condition: |r-1|+|c-1| <=1 yields exactly the center plus up/down/left/right -> that matches pattern. For n=5, condition <=2 gives diamond shape (a rotated square). Check pattern given: row0: D -> indices: 0,1,2,3,4; center =2; condition |r-2|+|c-2| <=2? For row0, |0-2|=2; so we need |c-2| <=0 => c=2 only. So only middle is D. That matches. Row1: DDD -> row1, |1-2|=1; so need |c-2| <=1 => columns 1,2,3. That matches three D's. Row2: DDDDD -> row2, |2-2|=0; need |c-2| <=2 => all columns 0-4. That matches. Then symmetric bottom.
So indeed pattern is: cell is 'D' if |r - ctr| + |c - ctr| <= radius where ctr = (n-1)/2, radius = (n-1)/2. Else '*'.
Since n is odd, we can loop rows i=0..n-1, cols j=0..n-1. Compute dist = abs(i - n//2) + abs(j - n//2) (since integer division). If dist <= n//2 then D else *.
We need output lines without spaces? The examples show contiguous characters. So just print each row as a string.
Constraints up to 101, trivial.
Thus solution is straightforward.
But maybe there is nuance: Input is a single integer. Output exactly pattern.
Implementation: read n, compute half = n//2. For i in range(n): construct list of chars: for j in range(n): if abs(i-half)+abs(j-half) <= half: char='D' else '*'. join and print.
Edge cases: n=3 works.
Let's check sample: n=5: half=2. row0: i=0 => dist_i=2; need dist_j <=0 => j=2 only. So "* * D * "? Actually we have " * D * "? Need to join: "D"? Actually row0: j=0: abs0-2=2 + abs0-2=2 =>4 >2 -> ''; j=1:2+1=3 >2 -> ''; j=2:2+0=2 <=2 -> D; j=3:2+1=3 -> ''; j=4:2+2=4 -> '*'. So "D". Good.
Thus correct.
But the problem statement says "diamond inscribed into it". Yes.
We can also compute using number of D's per row: from center outward, D count = 2* (half - abs(i-half)) + 1? Actually width of diamond row is something like: for row i, the number of D's = n - 2abs(i-half). But careful: For n=5, half=2. For i=0: n - 22 = 1, correct. For i=1: n - 21 = 3, correct. For i=2: n - 0 =5. So pattern: each row: leading stars = abs(i-half), then D repeated (n - 2abs(i-half)), then trailing stars same. So could also construct strings directly. But straightforward approach is fine.
Thus answer: implement as described.
Let's produce final answer with explanation.
But the user asked: "Twilight Sparkle once got a crystal from the Crystal Mine... You are given an odd integer n. You need to draw a crystal of size n." So they need code.
We'll provide solution in Python.
We'll output lines accordingly.
Now compose final message. ```python
def main():
import sys
data = sys.stdin.read().strip()
if not data:
return
n = int(data)
half = n // 2
code
for i in range(n):
row_chars = []
di = abs(i - half)
for j in range(n):
if di + abs(j - half) <= half:
row_chars.append('D')
else:
row_chars.append('*')
print(''.join(row_chars))