You can modify a clustering algorithm to suit your needs.
You can follow this Tutorial for Same-Size K-Means, or simply use this algorithm from the tutorial
package/module in ELKI (build the latest version from GitHub, because I just fixed a bug there - this will be included in ELKI 0.7.2).
Essentially, this algorithm performs a k-means style least-squares optimization, but all clusters must have the same size (if N/k is not integer, the cluster sizes may vary by 1).
If you go to above tutorial and scroll to the bottom, you can see example results.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…