I started an algorithm course in C two months ago, for the last weeks I've been trying to solve this problem , i ran out of time but I cannot find an acceptable solution. Basically It's a coin change problem, Given a sum (S) I need to find (and print) the combination that uses the least amount of coins, I can only use coins that are available. For example: INPUT: S=10 Coins={2,3,4,5} Supply={1,3,1,0} OUTPUT: 3 3 4

I've been able to solve the normal coin change problem but I can't seem to find a way to manage supplies so that the program doesn't use a coin when its supply=0.

  • $\begingroup$ Welcome to Computer Science! The title you have chosen is not well suited to representing your question. Please take some time to improve it; we have collected some advice here. Thank you! $\endgroup$ – Raphael Sep 26 '17 at 19:53
  • 1
    $\begingroup$ How does your current algorithm work? The canonical algorithm for this problem should be easy to extend for limited supplies. $\endgroup$ – Raphael Sep 26 '17 at 19:53
  • $\begingroup$ Where did you get stuck, in extending your current algorithm? We're happy to help you understand the concepts but just solving exercises for you is unlikely to achieve that. You might find this page helpful in improving your question. Have you tried dynamic programming? Check out our reference material on the subject: cs.stackexchange.com/tags/dynamic-programming/info $\endgroup$ – D.W. Sep 27 '17 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.