Practice/mediumX Pattern
⏱ 00:00
Best: 0/100
Diagonal IntersectionsTarget Time: 10 mins

X Pattern

Given an odd integer N, print an "X" pattern of size N x N where stars appear only on the main diagonal (i == j) and the anti-diagonal (i + j == N + 1).

Input Format
A single odd integer N.
Output Format
Print N rows forming an X pattern.
Constraints:1 <= N <= 21, N is odd
Concepts Required:
Main diagonal i == jAnti diagonal i + j == N + 1Coordinate plane geometry
Expected Pattern PreviewASCII Monospace
*   *
 * * 
  *  
 * * 
*   *

Notice how character spacing and row counts scale systematically based on the input N.

Concrete Examples

Example 1
Input:
5
Output:
*   *
 * * 
  *  
 * * 
*   *

Explanation: Diagonals intersect exactly at row 3, col 3.

← Back to All Challenges