Questions tagged [coin-change]

All problems (regardless of currency) with making change from a given amount of currency into a number of coins and bills of varying denominations.

All problems with making change from a given amount of currency into a number of coins and bills of varying denominations.

For example, finding the correct number of $20, $10, $5, $1 bills and $0.25, $0.10, $0.05, and $0.01 coins that add up to a given sum.

Variations of the problem are to find any solution, all the solutions, the one with the least number of coins / bills, or with a specific number of them.

260 questions
-1
votes
1 answer

Segmentation fault in recursive program

I am doing the coin problem, the problem says that, Given a set of coin values coins = {c1, c2,..., ck} and a target sum of money n, our task is to form the sum n using as few coins as possible. suppose you have 9 dollars and you have set of…
-1
votes
2 answers

algorithm for finding minimum number of coins for a given large sum

I just wanted to know if there is any efficient and optimal algorithm for the classical problem of finding the minimum number of coins that sum up to a number S where S can be very large (up to 10^16). In this case, the coins are (2, 5, 10). The DP…
ahmedgu
  • 51
  • 1
  • 6
-1
votes
1 answer

Coins changing algorithm problem - not working

I'm using the following algorithm for coins changing problem: for (let coin of coins){ if(change >= coin){ if (Math.floor(change/coin) > 0){ console.log(Math.floor(change/coin)+ " pièces de " + coin + " euro"); …
-1
votes
1 answer

How to use int output to calculate other output?

Create a Change application that prompts the user for an amount less than $1.00 and then displays the minimum number of coins necessary to make the change. The change can be made up of quarters, dimes, nickels, and pennies. Here is what I…
-1
votes
1 answer

Transform Java Class into program in C

I am creating a program that returns the rest with the minimum number of coins. In input I have a set of coins cuts and their amount. I did a java clone that works discreetly. Now I would need to turn it into C, a language I'm less prepared for. Can…
-1
votes
2 answers

Why am i getting a test case wrong in coin change dynamic programming approach?

I am trying to solve coin change problem using dynamic programming approach. What i have done is used a less space consuming one. Here goes my code: #include #include #include #include #include
Sarin Nanda
  • 35
  • 1
  • 7
-1
votes
2 answers

Coin change in C# with limited coins

I built the following coin change (C#) that works perfectly: class Program { static int amount = 0; static void Main(string[] args) { EnterAmount(); int[] coins = new int[] { 500, 100, 50, 20,…
Benoda
  • 133
  • 1
  • 10
-1
votes
1 answer

how to exchange an amount of money into notes and coins

how can I exchange a given amount of money into notes and coins? lets say input is 1234,26 and we have notes for 1000, 500, 200, 100, 50, and coins for 20, 10, 1, and 0.5? so if input is greater than .25 and less than .75 it should be rounded to 1x…
gger234
  • 149
  • 7
-1
votes
1 answer

dynamic programming, coin change, memory leak?

I writing program to change coin. When i write printf in loops to print i or j program give good results, when I delete it, program stops. I think it's problem with memory but I'm writing on Windows in QT and i have no access to valgrind. Anyone…
-1
votes
2 answers

Minimum amount of change c++

I need to give the minimum amount of change possible.I input number of cases,each case had a number of coins(1 is not necessarily a part of them) and the number of number I want to test.Then I enter the different coins and the different number to…
LoveMeow
  • 3,858
  • 9
  • 44
  • 66
-1
votes
1 answer

Coin Exchange in java Code stackOverflowError

cannot find the problem, everytime when I'm running this code it goes stackoverflow due to this line countCombine += count(array,money - (array[i]*(int)(money/array[i]))); basically problem is very easy. Given a value N, if we want to make change…
gauravds
  • 2,931
  • 2
  • 28
  • 45
-1
votes
1 answer

Coin change with different upper bounds on different coins?

Sample Input: 20 10 2 5 2 Sample Output: 2 Explanation: An amount of 20 could be made in 2 ways: 10*2 10*1 + 5*2 I want to find out the number of ways a particular amount can be made with given coins.In the sample input 20 is the amount to be made…
-2
votes
2 answers

Python syntax errors - coin machine problem

I know these are very basic questions but cannot figure out what I'm doing wrong. I'm just beginning to learn python and don't understand why I am getting a syntax error every time I try to subtract something. When I try to run this: ```#def…
Lily
  • 1
  • 1
-2
votes
2 answers

Coin change - python

My denomination "5" is not showing up and how do you reverse the dict easily. i dont want extra 5 line of code.lol Can you guys help me out with it? the code is working so far. here is my code with a test case def change(target, coins): result…
-2
votes
1 answer

Return change program decimals c++

An exercise for my programming class requires us to write a program for a cashier that prompts the amount of money due and the amount of money received and calculates the change. It also must calculate the amount of dollars, quarters, dimes,…
captaincp
  • 1
  • 1
1 2 3
17
18