There are elements and their height is known. They need to be distributed on 3 columns and seeks to ensure that the height of these columns was the same. That is, arrange n elements in m columns. One element can be only in one column, and in one column there can be any number of elements.

How exactly is the task called and are there any similar implementations in javascript?

enter image description here Bad option. In the first column there are a lot of elements and in the second and third there are few.

enter image description here A good option. The elements are evenly distributed in columns and the height is chosen correctly.

  • and what exactly needs to be optimized? the difference in the sum of heights? In general, what is the optimality criterion. - pavel
  • @OlmerDale, in spite of the fact that we still don’t have a formal criterion for location success, I think that it’s impossible to achieve the best result with just one sort. - Duck Learns to Take Cover
  • The optimality criterion is the difference in the sum of the heights of all columns, the smaller the better. That is, the speakers should strive to be the same height. Added pictures. - manking
  • The number of columns can be any? Or is it necessary to look for the minimum number of columns under which the condition is met? - ThisMan
  • No, not all, but 3 columns. - manking pm

0