Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Coordinates as immutable records

Python data engineering interview problem. Difficulty: beginner. Pattern: Searching. About 10 minutes. Part of the Pro drill bank.

A warehouse stores pickup coordinates. Dispatch wants the stored point closest to a reference location. Coordinates should be treated as immutable records, not loose tuples you accidentally mutate.

Given stored points and a reference point, return the closest coordinate record.

Requirements

  • Use an immutable record type for a point (named tuple or equivalent).
  • Closest means smallest Euclidean (or squared) distance.

Constraints

  • points: a collection of coordinate records.
  • ref: the reference coordinate.
  • There is at least a defined behavior for a single point.
  • Ties should follow the tests.

Examples

Input: closest_coordinate([(0, 0), (2, 2)], (1, 1)) Output: (0, 0) This input follows the stated rules and produces this output.

Topics: lakebench, python, tuples.

More Python interview questions · All interview problems · Learn data engineering

beginner

Coordinates as immutable records

Interview-style drill: Given a list of (lat, lon) tuples, return the pair closest to a reference point.

Given stored points and a reference point, return the closest coordinate record.