I was counting some coins and was wondering if some coins should be produced more frequently because they would be used more often so I wrote an minimized change count algorithm to decide if certain coins should be produced more often.
The code below should prove my chart to be valid.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from collections import Counter
def count_coins(val):
dict = Counter()
oldval = val
while val > 25:
dict[25] = dict[25] + 1
val = val - 25
while val > 10:
dict[10] = dict[10] + 1
val = val - 10
while val > 5:
dict[5] = dict[5] + 1
val = val - 5
while val != 0:
dict[1] = dict[1] + 1
val = val - 1
return dict
tot_counter = Counter()
for amount in range(1, 99):
coins = count_coins(amount)
for key in coins:
tot_counter[key] += coins[key]
print(tot_counter)