title: calculating 3 similar sized groups in Javascript or jQuery
body: <p>We have:</p>
  
  <pre><code>var range = [9,18,3,14,2,6,12,7,11,2,1,4]
  var total = 89;
  var group_size = total / 3;
  </code></pre>
  
  <p>As result I need 3 groups similar sized but     group1 and     group2 can never be bigger than     group_size.</p>
  
  <p>The result for this example would be</p>
  
  <pre><code>var group1 = 27; // 9,18
  var group2 = 25; // 3,14,2,6
  var group3 = 37; // 12,7,11,2,1,4
  </code></pre>
  
  <p>How can I achieve this in Javascript/jQuery?</p>