title: Variant on Cutting Stock in Mathematica
body: <p>So I'm pretty new to Mathematica, and am trying to learn to solve problems in a functional way. The problem I was solving was to list the ways in which I could sum elements from a list (with repetitions), so the sum is leq to some value. The code below solves this just fine.</p>
  
  <pre><code>i = {7.25, 7.75, 15, 19, 22};
  m = 22;
  getSum[l_List, n_List] := Total[Thread[{l, n}] /. {x_, y_} -&gt; x y];
  t = Prepend[Map[Range[0, Floor[m/#]] &amp;, i], List];
  Outer @@ %;
  Flatten[%, ArrayDepth[%] - 2];
  Map[{#, getSum[i, #]} &amp;, %];
  DeleteCases[%, {_, x_} /; x &gt; m || x == 0];
  TableForm[Flatten /@ SortBy[%, Last], 0, 
   TableHeadings -&gt; {None, Append[i, "Total"]}]
  </code></pre>
  
  <p>However, the code check a lot of unneccesary cases, which could be a problem if m is higher of the list is longer. My question is simply what would be the most Mathematica-esque way of solving this problem, concerning both efficiency and code elegancy. </p>