WOLFRAM|DEMONSTRATIONS PROJECT

Coin Machine

​
Coin Machine
1¢
5¢
10¢
125
+1
-1
130
+1
-1
100
+1
-1
25¢
50¢
$1
150
+1
-1
120
+1
-1
110
+1
-1
amount:
amount in ¢
30
available coins:
1¢
5¢
10¢
25¢
50¢
$1
number of coins:
735
total amount of money [$]:
225.25
algorithm:
Greedy
Optimal
Random
propose change
coinage system [¢]
1.
5.
10.
25.
50.
100.
The greedy algorithm is optimal.
change
1¢
5¢
10¢
25¢
50¢
$1
-
-
-
-
-
-
give change
This Demonstration shows a coin machine. Coins are available in denominations of 1, 5, 10, 25, and 50 cents and 1 dollar. Specific coins can be excluded and you can refill the machine. The coin machine can provide change for a given amount of money. Three algorithms are presented: the greedy algorithm, the optimal algorithm for the given system, and a random algorithm.