Compare commits

...

3 Commits

Author SHA1 Message Date
Joe S ab881dd578 Final fix to exact change 2021-01-23 19:36:45 -05:00
Joe S d27d5025fb Boring exact change solution 2021-01-23 18:47:51 -05:00
Joe S cb99c6af49 Adjust the default logging level 2021-01-23 17:04:13 -05:00
2 changed files with 41 additions and 1 deletions

View File

@ -1,7 +1,7 @@
from datetime import datetime from datetime import datetime
import logging import logging
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.ERROR)
input_month = input('Input a month to analyse: ') input_month = input('Input a month to analyse: ')
input_day = int(input('Input a day of that month: ')) input_day = int(input('Input a day of that month: '))

View File

@ -0,0 +1,40 @@
try:
user_cents = int(input('Cents: '))
except ValueError:
print('Cannot cannot parse input.')
exit()
change = []
coins = [
['Dollars', 'Dollar'],
['Quarters', 'Quarter'],
['Dimes', 'Dime'],
['Nickels', 'Nickel'],
['Pennies', 'Penny']]
while user_cents >= 100:
user_cents -= 100
change.append(coins[0])
while user_cents >= 25:
user_cents -= 25
change.append(coins[1])
while user_cents >= 10:
user_cents -= 10
change.append(coins[2])
while user_cents >= 5:
user_cents -= 5
change.append(coins[3])
for _i in range(user_cents):
change.append(coins[4])
if len(change) != 0:
for coin in coins:
num_coins = change.count(coin)
if num_coins != 0:
if num_coins > 1:
print('{0} {1}'.format(num_coins, coin[0]))
else:
print('{0} {1}'.format(num_coins, coin[1]))
else:
print('No change ')