I am trying to divide a list of string into 4 sublist (which should have all elements of original list balanced among them). I have tried following approach but i am getting reminder elements into a 5th list. I need only four sublists and reminder must be adjusted into these four list only
def sublists = localities.collate(localities.size().intdiv(4))
for(sublist in sublists){
println(sublist.join(','))
println "next"
}
here localities is having around 163 elements, I am getting output as 4 list of 40 and 5th list of size 3.. my localities list is dynamic and could have variable number (will always be above 100) . i need to get only 4 list, where reminder of 3 elements are adjusted in 4 list.