pythonnumpy
Ben Gorman

Ben Gorman

Life's a garden. Dig it.

After binge watching the discovery channel, you ditch your job as a trial lawyer to become a gold miner :material-gold: :material-excavator:. You decide to prospect five locations underneath a 7x7 grid of land. How much gold do you uncover at each location?

import numpy as np
 
np.random.seed(5555)
gold = np.random.randint(low=0, high=10, size=(7,7))
 
print(gold)
# [[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]]
 
locs = np.array([
    [0,4],
    [2,2],
    [2,3],
    [5,1],
    [6,3]
])

Notes

  • gold states how much gold is under each location in the 7x7 grid of land
  • locs states the coordinates of the five locations where you dig

Solution

This content is gated

Subscribe to one of the products below to gain access