Skip to content

Instantly share code, notes, and snippets.

Created January 30, 2014 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8703925 to your computer and use it in GitHub Desktop.
Save anonymous/8703925 to your computer and use it in GitHub Desktop.
Fernando Ramirez First ever submission
1)reverse sort the list
First loop
2)Take the first number,n_1, the largest number, in the list and check if its less than the given number. If it is not move on to the next number
3)Now say that target number is x. find b = x modulus n_1.
4)if the modulus is zero, then make a combination of x/n_1 times of that denomination.
5)If it is not zero,(loop 3) then go through list in reverse and find a number that is equal to or less than the remainder b.
6)If you find a number that is equal to, then list that number in combination with x-b/n_1 of the initial number and b.
7)if it is less than b then make number b_1 = b - m_1. go back to step 5
8) If the end of the list is found then find f = x - n_1
9)if f is nonzero return to step 3 with x = x-n_1
10) If f is zero then return to step 2
Finish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment