|
General Details
|
|
Ruby
|
|
Posted 97 Days Ago
|
|
430 Views
|
|
Received 0 Ratings
|
|
Number of ways to make change using Memoization
Description
This is a program I made to solve the following challenge:
"Given the a list of coin amounts, and a final amount, your program should calculate how many different ways there are to make change for the final amount using the various coins.
Your program should input:
1) The final sum
2) The number of different coins
3) The various coins
You can gather this information in any way you want.
There should always be a 0.01 coin to ensure all possible amounts can be changed. Therefore, there should always be at least one kind of coin."
http://www.newgrounds.com/bbs/topic/959858
This particular solution uses memorization(remembering previous calculations for when you need them) to calculate the result fairly quickly.
Technical
Sample run:
Amount to change: 1.00
Number of coins: 5
Coin 1: 0.01
Coin 2: 0.05
Coin 3: 0.10
Coin 4: 0.25
Coin 5: 0.50
There are 292 different ways to make change for $1.0
Source Code
Comments
| Please login to post comments. |
More "Ruby" Source Codes By This Author
Recently Posted "Ruby" Source Codes
Recently Rated "Ruby" Source Codes
|