Ex
Exerpad
🔥0
0 XP
Lv.1 Beginner

Rhombus

Read an odd number N from input and create an N x N grid with a rhombus (diamond) shape.

A cell is inside the rhombus if abs(row - center) + abs(col - center) <= center, where center = N // 2.

Use "blue" for the rhombus and "white" for the background.

Don't change the print statements at the bottom.

python
n = int(input())
center = n // 2
grid = []
# Create N x N grid
# If abs(row - center) + abs(col - center) <= center: "blue"
# Otherwise: "white"


__grid__ = grid

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