Visual representation of the matrix with code that generate the picture (I use matplotlib==3.8.4):
def show_snail(n) -> None:
import matplotlib.pyplot as plt
matrix = square(n)
# Using matplotlib to create a heatmap of the matrix
plt.figure(figsize=(8, 8))
plt.imshow(
matrix, cmap="viridis"
) # You can choose any colormap like 'viridis', 'hot', 'cool', etc.
plt.gca().set_position(
[0, 0, 1, 1]
) # Set the axes to fill the whole figure area
plt.gcf().set_size_inches(w=1, h=1)
plt.axis("off") # Hide the axes
plt.show()
show_snail(5)
