Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [change-making-problem]

The change-making problem is to find the minimum number of bills and coins that total to a given sum of money.

5
votes
2answers
228 views

Calculating the number of coins in money change

I wrote a program that calculates the minimum number of coins required to give a user change. One concern I have is: When do we initialize the value of a float to be negative or positive? I recently ...
5
votes
1answer
522 views

Script that counts quarters, dimes, nickels, and pennies

I am learning Python and I wrote a script that counts how many coins you would need for an amount in dollars. I was wondering if I could make any improvements to it. ...
3
votes
1answer
61 views

Dividing an arbitrary dollar amount into the fewest bills and coins

I am taking a class in mobile application development this fall. I have finished my first assignment of creating a class to divide an arbitrary dollar amount into the minimum number of bills and coins....
1
vote
1answer
616 views

Optimal change with only with two euros coins and five and ten euros bills

We assume we have unlimited number of coins and bills. My code works fine but the method optimalChange() has a Cyclomatic Complexity of 8. ...
2
votes
2answers
264 views

Calculate how many coins, coin values are 50, 20, 10 and 5

The code should enter an integer between 5-95 and calculate how many coins, coin values are 50, 20, 10 and 5. My concern is the CalcChange function and whether ...
2
votes
2answers
3k views

Find the minimum number of coin change

Description: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that ...
3
votes
1answer
162 views

Calculate change denominations 3

I am trying to refactor a large application to use more DDD principles as and when I get chance. I am concentrating on the very simple areas first. The app currently has a very simple Domain Service ...
1
vote
1answer
658 views

Project Euler Problem 31 (Coin Sum)

I just finished Project Euler 31: Coin sums, which asks how many ways there are to make £2 using British coins (1p, 2p, 5p, 10p, 20p, 50p, £1, and £2). When I compared my code and the problem review'...
3
votes
5answers
884 views

Creating change with the smallest number of coins

This is a basic algorithm that creates change with the smallest number of coins. How can this be better written? It works perfectly, but I just imagine there is a cleaner and shorter version of this. ...
5
votes
5answers
2k views

Change return program

I did an application that returns you quarters, dimes, nickels and pennies after you give the cost of the product and the money you gave. Can this be done any better? This seems like kind of messed up,...
3
votes
3answers
967 views

Vending machine change function

Write a function that takes an amount of money M, a price P and returns the change given in the smallest number of coins. The ...
6
votes
1answer
1k views

Return the amount of Quarters, Dimes, Nickels, and Pennies that you would get from the total amount of change [closed]

I made windows form in C# that takes the amount of change given, 1-99 and tells you the amount of quarters, dimes, nickels, and pennies you would get back. Can I improve the math in any way? It takes ...
-3
votes
1answer
2k views

Counting the number of ways to break an amount into coins

I have an algorithm here that counts the number of ways that n cents can be represented using the following denominations: quarter: 25 cents dime: 10 cents nickel: 5 cents pennies: 1 cent There are ...
2
votes
1answer
527 views

Coin Change Problem with Memoization

Purpose Another take on the classic Change-making Problem: Given some set of coins and a value, find the minimum number of coins necessary to add up to this value In my implementation, instead of ...
4
votes
2answers
2k views

Make change for a given amount given denominations

Make change like at a cash register Input is the denominations of the currency and the sum In test case only coins are entered Return how many of each denomination Return the fewest possible ...
3
votes
1answer
87 views

CS50 Pset1 Greedy, change algorithm

The purpose of the code is to calculate the least amount of coins needed to produce correct amount of change given a dollar or cent user input. I'm just starting out and appreciate any pointers in how ...
5
votes
5answers
357 views

Decimal Quantities needed to meet cost

I asked this question recently: Finding the number of capital letters in a word grouped by letter. The answerer answered my specific question so I have marked it as answered. However, I would like ...
2
votes
1answer
996 views

Coin change with Dynamic Programming

I have made an implementation of coin change problem solved with Dynamic Programming. Could you guys help with renaming some method and variables? Here is my implementation - ...
2
votes
1answer
335 views

How many ways we can make the change of the amount using the coins given

Given a set of coins and amount, write an algo­rithm to find out how many ways we can make the change of the amount using the coins given. Exam­ple: Amount = 5 ...
6
votes
2answers
272 views

Coin Change Kata in ImmutableJS

I'm preparing for a job as a junior/intermediate JS developer. I'm comfortable with my ability to think in higher-order functions, but less confident in my syntax and style (I have more experience in ...
4
votes
1answer
553 views

Change-Making Problem Solution

Please take a moment and review my code and tell me how I did. This is the first time in my class (CSC 111) I've been given an assignment in which I had to use a lot of my own resources and develop ...
8
votes
3answers
275 views

A program to represent a coin amount using the smallest number of coins

Recently, I was learning about greedy algorithms. One example that was given was an algorithm for exchanging a given money amount using the smallest number of coins. After the lecture, I wrote a C ...
5
votes
3answers
1k views

Give me some change as asked in interview

Description: The goal in this problem is to find the minimum number of coins needed to change the input value (an integer) into coins with denominations 1, 5, and 10 The input consists of ...
6
votes
1answer
3k views

Coin change algorithm

I've implemented the coin change algorithm using Dynamic Programming and Greedy Algorithm w/ backtracking. The description is as follows: Given an amount of change (n) list all of the possibilities ...
5
votes
2answers
925 views

Change-making problem with specific constraints

I am a new Pythoner. I have solved a OJ project with Python. Can you tell me how can I solve it more Pythonically? Problem Description: There are n coin denominations, each with an unlimited ...
5
votes
1answer
4k views

Given a monetary amount, calculate the equivalent change

I have written a program that takes in some amount of money, and prints the equivalent change (starting at hundred dollars, to fifty, to twenty, down the pennies). Here is the code: ...
4
votes
2answers
954 views

Bills dispenser machine

I have just started out learning C++ and I am trying to write out a simple bills' dispenser machine as an exercise. Upon user input, the system is to check if it can pay out the amount but only in 20 ...
3
votes
2answers
6k views

Converting money into change

I am trying to figure out a more efficient way of converting money into change. The code below is what i have written so far. It works perfectly but i know the code can be improved. Is there a more ...
3
votes
1answer
78 views

Calculating change in Ada

I have written a change calculator using Ada. when the user inputs an amount of money it returns a list of the coins and bills needed to create that total. It starts off by trying to use the largest ...
10
votes
3answers
2k views

Coin Change: Minimum number of coins

Problem: You are given n types of coin denominations of values \$v(1) < v(2) < ... < v(n)\$ (all integers). Assume \$v(1) = 1\$, so you can always make change for any amount of money \$C\$....
5
votes
1answer
1k views

Implementation of the change making algorithm

I wrote a set of python classes for solving the change making problem, in various forms. Given the coin denominations and values: Find all possible ways of making change. Find a best way ...
14
votes
6answers
17k views

Find Minimum Number of coins

Please be brutal, and treat this as a top 5 technical interview. I am trying to follow Google's way of writing Java code, as per their .pdf file online of code review. (Side note: do any of you see ...
4
votes
1answer
2k views

More optimal “Making Change” Problem: Knapsack challenge

The problem description is: You are given n types of coin denominations of values v(1) < v(2) < ... < v(n) (all integers). Assume v(1) = 1, so you can always make change for any ...