Ex
Exerpad
🔥0
0 XP
Lv.1 Beginner

Concentric Squares

Read a number N from input and create an N x N grid with concentric square rings that alternate between two colors.

Each cell's ring number is its minimum distance to any edge: min(row, col, N - 1 - row, N - 1 - col).

Use "coral" for even rings (0, 2, 4...) and "teal" for odd rings (1, 3, 5...).

Don't change the print statements at the bottom.

python
n = int(input())
grid = []
# Create N x N grid
# ring = min(row, col, n - 1 - row, n - 1 - col)
# Even ring: "coral", odd ring: "teal"


__grid__ = grid

# Don't change below this line
print(len(grid))
print(grid[0][0])
print(grid[1][1])
print(grid[2][2])
Exerpad — Learn to Code with Fun!