Challenge - Gold Miner¶
After binge watching the discovery channel, you ditch your job as a trial lawyer to become a gold miner. You decide to prospect five locations underneath a 7x7 grid of land. How much gold do you uncover at each location?
In [1]:
%pip install numpy
import numpy as np
np.random.seed(5555)
gold = np.random.randint(low=0, high=10, size=(7,7))
print(gold)
locs = np.array([
[0,4],
[2,2],
[2,3],
[5,1],
[6,3]
])
Requirement already satisfied: numpy in /home/samrat/Documents/numpy-torch-tutorials/venv/lib/python3.8/site-packages (1.24.4) Note: you may need to restart the kernel to use updated packages. [[2 3 0 5 2 0 3] [8 8 0 7 1 5 3] [0 1 6 2 1 4 5] [4 0 8 9 9 8 7] [4 2 7 0 7 2 1] [9 8 9 2 5 0 8] [1 9 8 2 6 4 3]]
In [7]:
print(locs[:, 0])
print(locs[:, 1])
gold[locs[:, 0], locs[:, 1]]
[0 2 2 5 6] [4 2 3 1 3]
Out[7]:
array([2, 6, 2, 8, 2])