Approach how to solve it

5 5 5 5 5
5 4 4 4 5
5 4 3 4 5
5 4 4 4 5
5 5 5 5 5

The logic behind this is -
You assume the ends of the matrix as walls , such as - Top wall,Lower wall, left wall and right wall.
Now you need to subtract the min(wall) from n .Such as -

for i in range(n):
    for j in range(n):
        print(n-min(i, j, n-i-1, n-j-1),end='' )
    print()