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
0
votes
4 answers

How to convert currency amount to change?

Given a dollar amount convert it into euro coins and bills. You are given the dollar amount as the argument, and said that the dollar to euro rate is 1.30. You are given that euro denomations are 500 bill, 200 bill, 100 bill, 50 bill, 20 bill,…
Rahul Chowdhury
  • 641
  • 1
  • 7
  • 16
0
votes
1 answer

Minimum coin change or 0-1 knapsack

I have data set like this: Length: 233, 333, 450, 560, 650, 780 Limit: 5400 Now my problem is to choose item from length set highest to lowest to make up the limit or come as close as possible. I know both knapsack and minimum coin change can solve…
0
votes
3 answers

I need to write a dispense change program.I completed the code,but it has some problem.Please help me to debug the code

There is a question in "Problem Solving and Program Design in C" book.I wrote the code, but loop isn't terminating. #include #include void change(double coin_change, int *quarters, int *dimes, int *nickels, int *pennies); int…
mustafaSarialp
  • 265
  • 1
  • 7
  • 17
0
votes
1 answer

How to find overlapping subproblem in coin change problem of this recursive code i can't find one

You are working at the cash counter at a fun-fair, and you have different types of coins available to you in infinite quantities. The value of each coin is already given. Can you determine the number of ways of making change for a particular number…
0
votes
1 answer

On withdraw coinpayments error message "Transaction value exceeds per-TX limit!"

I'm trying to create a withdraw with LTCT using the coinpayments api with this PHP code I've tried using CreateWithdraw method and ConvertCoins $amount = (float)$total; // in usd $currency1 = 'LTCT'; $add_tx_fee = 0; // 0 receiver pays for…
Adriel Werlich
  • 1,982
  • 5
  • 15
  • 30
0
votes
0 answers

Recursive Function for Coin Change algorithm returning an empty list

I'm working on a recursive function which renders change in available combination of coins against a given quantity. The expected behavior is not achieved though in some cases. For example: when the available coins are {9,5,3} and total is 21 or 30…
USQ91
  • 342
  • 1
  • 4
  • 16
0
votes
0 answers

dynamic pseudo code for simplified coin changing algorithm

As a homework exercise our professor presented to us a simplified version of the coin-changing problem in which we do not need to minimize the number of coins used or track the number of possible combinations. Instead we need only to determine if a…
Trixie the Cat
  • 317
  • 3
  • 18
0
votes
2 answers

Coin Change Recursion All Solutions to Distinct Solutions

I am new to recursion and backtracking. I know I need to be completely comfortable with these concepts before I move on to dynamic programming. I have written a program below that helps me find all the possible combinations for a given amount n and…
Spindoctor
  • 434
  • 3
  • 17
0
votes
1 answer

Minimum Coin Change (Infinite, Unbound) Print the values

The following function gets the minimum number of coins that should sum up or cover an amount. for example: If I have coins: [6,11] and I need minimum coins to get 13 then the answer should be 2 (which 11, 6) and these are the minimum number of…
0
votes
1 answer

What Are the Ideas Behind Variations of the Coin Change Problem?

Problem: given a set of n coins of unique face values, and a value change, find number of ways of making change for change. Assuming we can use a denomination more than once, here's the pseudocode I came up with 1. NUM-WAYS(denom[], n,…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
0
votes
3 answers

Coin Change Algorithm JS

I have been trying to come up with a solution for this algorithm for 3-4 days but nothing seems to work and the available solutions are a bit more advanced for me. It has to be solved with conditionals only so no recursion or dynamic programming. I…
user10552408
0
votes
1 answer

Coin change problem C++

I am having a problem with writing a dynamic algorithm to solve coin change problem what I got is this: arr[value] - a global array filled with 0, lenght of the value I want to solve; a[n] - an array with coin values; void dynamic(int n, int *a,…
Paul
  • 163
  • 7
0
votes
1 answer

Why would my function definition start to throw a syntax error?

To start, I'm a beginner when it comes to working with python. I'm writing a function for the coin-change problem, with additional constraints (find the best way to pay given a list of the amount of each coin type and their value). The function was…
0
votes
1 answer

Why is a variable in my coin-changing (DP) function changing?

The task is to write a function to make change for an amount using a given denomination of coins (coins = [200, 100, 50, 20, 10, 5, 2, 1]), given the coins in 'pocket' e.g a pocket of [1,0,1,0,5,0,3,0] would represent 1x£2, 1x£0.50, 5x£0.10 and…
0
votes
2 answers

Coin change algorithm

would just like to double check this code will not have any errors, mainly to do with the modulus operator I'm unsure about. The question is: Problem: Write an ACL algorithm that, given a cost of an item (less than or equal to one dollar), gives the…