Divide Equally
Sort a list of random numbers into three lists of similar sum
3bowlsDS.zip
2KB
Binary
1
//Sorting into three lists
2
nSrt=List.Reverse(List.Sort(n));
3
nSbL=List.Chop(nSrt,3);
4
lst1=List.Transpose(List.TakeEveryNthItem(nSbL,2,-1));
5
lst2=List.Transpose(List.Reverse((List.TakeEveryNthItem(nSbL,2,0))<1>));
6
7
//Three sublists with the sum of numbers more or less the same
8
lst3=(List.Transpose([List.Shuffle(lst1<1>),List.Shuffle(lst2<1>)]));
9
lst4 = List.Flatten(List.Clean(lst3,false)<1>,-1);
Copied!
Last modified 1yr ago
Copy link