title: Algorithm to price bulk discounts
body: <p>i am designing a Chinese auction website.</p>
  
  <p>Tickets ($5, $10 &amp; $20) are sold either individually, or via packages to receive discounts.
  There are various Ticket packages for example:</p>
  
  <ol>
  <li>5-$5 tickets = receive 10% off</li>
  <li>5-$10 tickets = receive 10% off</li>
  <li>5-$20 tickets = receive 10% off</li>
  <li>5-$5 tickets + 5-$10 tickets + 5-$20 tickets = receive 15% off</li>
  </ol>
  
  <p>When users add tickets to their cart, i need to figure out the cheapest package(s) to give them. the trick is that if a user adds 4-$5 tickets + 5-$10 tickets + 5-$20 tickets, it should still give him package #4 since that would be the cheapest for him.</p>
  
  <p>Any help in figuring out a algorithm to solve this, or any tips would be greatly appreciate it.</p>
  
  <p>thanks</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>i figured out the answer, thanks all, but the code is long.</p>
  
  <p>i will post the answer code if anyone still is interested.</p>