Solve the knapsack problem
Mathematica, 59 chars 

Tally/@IntegerPartitions[#1,All,#2/._[x_,_]-&gt;x]/.#2/.{}-&gt;X&amp;


Invoke with

%[1505, {215 -&gt; "MF", 275 -&gt; "FF", 335 -&gt; "SS", 355 -&gt; "HW", 420 -&gt; "MS", 580 -&gt; "SP"}]