Skip to content
C

Problem 3: Manually Group Points by a Distance Threshold

Easypython

Problem Description

Write a Python program that manually groups points into clusters based on a simple rule: any two points within a given distance threshold of each other belong to the same cluster (a simplified, conceptual precursor to more formal clustering algorithms).

Input

A list of 2D points and a distance threshold.

Output

The resulting groups of points.

Constraints

  • At least 6 points.

Example Input

text
points=[[1,1],[1.5,1.5],[8,8],[8.5,8.5]], threshold=1.0

Example Output

text
Cluster 1: [[1,1],[1.5,1.5]] Cluster 2: [[8,8],[8.5,8.5]]

Concepts Covered

Distance calculation, conditional grouping logic.

Input (stdin)

Output

Run your code to see output here...