🧭 Do not search for the first 15 minutes. When stuck: re-read the requirements → define I/O → choose the data structure → trace a small example by hand → write code.
Find clusters with Lloyd's algorithm. k-means normally seeds its centroids at random, but this problem has no randomness — the initialization is fixed so the answer is unique.
X # (n, d) real-valued features
k # cluster count (at least 1, at most n)
iters # iteration count (0 or more)
If X arrives one-dimensional, treat it as (n, 1).
k rows of X. They are not sampled.iters times:
With iters=0 the initial centroids are the answer.
kmeans(X, k, iters) → a list of k centroid coordinates (each a list of length d),
every float rounded to 6 decimal places.
Implement kmeans(X, k, iters).
k rows of X — not random.iters times.k coordinate lists, each value round(v, 6).