y = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]])
indices_of_y = np.array([12, 0, 6, 3, 4, 9, 11, 2])
z = np.array([1 , 1, 0, 1, 1, 1, 0, 0])
x = np.array([1, 1, 1, 0, 1, 0, 0, 1])
n = 3
I want to compare arrays z and x element wise and I want to add n to only those elements of y where the elements of z and x differ. In the case that the elements of z and x are different, I add n to the element of y in the index position indicated in indices_of_y.
The answer should be:
y = [1, 2, 6, 7, 5, 6, 10, 8, 9, 13, 11, 12, 13, 14, 15, 16]