title: Calculate all possibilities to get N using values from a given set
body: <p>So here is the problem:</p>
  
  <p>Given <code>input = [100 80 66 25 4 2 1]</code>, I need to find the best combination to give me 50. </p>
  
  <p>Looking at this, the best would be 25+25 = 50, so I need 2 elements from the array.</p>
  
  <p>Other combinations include <code>25+4+4+4+4+4+4+1</code> and <code>25+4+4+4+4+4+2+2+1</code>.. etc etc</p>
  
  <p>I need to find all the possibilities which gives me the sum on a value I want. </p>
  
  <p>EDIT: As well as the best possibility (one with least number of terms)</p>
  
  <p>Here is what I have done thus far:
  First build a new array (simple for loop which cycles through all elements and stores in a new temp array), check for all elements higher than my array (so for input 50, the elements 100,80,66 are higher, so discard them and then my new array is [25 4 2 1]). Then, from this, I need to check combinations.</p>
  
  <p>The first thing I do is a simple if statement checking if any array elements EXACTLY match the number I want. So if I want 50, I check if 50 is in the array, if not, I need to find combinations.</p>
  
  <p>My problem is, I'm not entirely sure how to find every single combination. I have been struggling trying to come up with an algorithm for a while but I always just end up getting stumped. </p>
  
  <p>Any help/tips would be much appreciated.</p>
  
  <p>PS - we can assume the array is always sorted in order from LARGEST to SMALLEST value.</p>