Splitting up a list into different length parts under special condition
问题 I need an algorithm of dividing different manufacturing parts in to uneven groups. The main condition is that difference between maximum number in the group and all others should be as low as possible. For example: if we have list [1,3,4,11,12,19,20,21] and we decide that it should be divided in 3 parts it should be divided into [1,3,4],[11,12],[19,20,21] . In the same case if we decide to divide it in to 4 we would get : [1,3,4],[11],[12],[19,20,21]. In order to clarify "difference between