title: Consuming a number into descending groups
body: <p>I always struggle with these types of algorithms.  I have a scenario where I have a cubic value for freight and need to split this value into cartons of different sizes, there are 3 sizes available in this instance, 0.12m3, 0.09m3 and 0.05m3.  A few examples;</p>
  
  <p>Assume total m3 is 0.16m3, I need to consume this value into the appropriate cartons.
  I will have 1 carton of 0.12m3, this leave 0.04m3 to consume.  This fits into the 0.05m3 so therefore I will have 1 carton of 0.05m, consumption is now complete.  Final answer is 1 x 0.12m3 and 1 x 0.05m3.</p>
  
  <p>Assume total m3 is 0.32m3, I would end up with 2 x 0.12m3 and 1 x 0.09m3.</p>
  
  <p>I would prefer something either in c# or SQL that would easily return to me the results.  </p>
  
  <p>Many thanks for any help.</p>
  
  <p>Cheers</p>