I have a question about increasing a value by 1 from the center.
Write a function border(x) that takes a positive odd integer x as input, and returns an array of floats y of shape(x,x) that has the following properties:
the centre of the generated array y is 0
with each subsequent border, the number of that border increases
the expected output are below for example:
border(3)
[ [1. 1. 1.],
[1. 0. 1.],
[1. 1. 1.] ]
border(5)
[ [ 2. 2. 2. 2. 2.]
[ 2. 1. 1. 1. 2.]
[ 2. 1. 0. 1. 2.]
[ 2. 1. 1. 1. 2.]
[ 2. 2. 2. 2. 2.] ]
I have come up with this part and don't have any more ideas to increase the value along the border. pls help me.
x = 5
a = numpy.ones((x,x))
c = x//2
a[c,c]=0
print(a)
[[1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1.]
[1. 1. 0. 1. 1.]
[1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1.]]