Peanut Butter Problem¶
Given peanut
, a 4x5 array of 0s, and butter
, a 5-element 1-d array of indices, fill the rows of peanut
with 1s
starting from the column indices given by butter
.
import numpy as np
peanut = np.zeros(shape = (4, 5))
butter = np.array([3, 0, 4, 1])
print(peanut)
# [[0. 0. 0. 0. 0.]
# [0. 0. 0. 0. 0.]
# [0. 0. 0. 0. 0.]
# [0. 0. 0. 0. 0.]]
print(butter)
# [3 0 4 1]