Project 25: Nearest Active User Finder
Scientific Computing
Current Task
Objective
Review day: reuse a KDTree — day 13 — to find the nearest active user instead of the nearest job.
Task: build a KDTree of user positions and query the nearest one to a given point.
index.py
from scipy.spatial import KDTree
import numpy as np
user_positions = np.array([[0, 0], [3, 3], [1, 1]])
tree = KDTree(user_positions)
distance, index = tree.query([0.5, 0.5])
print(distance, index)
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview