The question is following: Given number K and some data, classify and put data into K buckets.
This is silly atempt to address this question by implementing k-means, the most basic classification algorithm. For simplicty and visbility reasons I've choosen data to be 2d points on the surface.
Overall algorithm's yield is very much depends on data distribution ( are they allready "split" into K buckets or spread randomly?) and on the choice of first pivot points. Therfore on some occasions it can split data ideally but next time it can be completly wrong.
Left: raw data, Right: after classification to buckets ( via color )
Same, but for larger gravity values:
Fail case: