Problem Statement
You have x no. of 5 rupee coins and y no. of 1 rupee coins. You want to purchase an item for amount z. The shopkeeper wants you to
provide exact change you want to pay using minimum number of coins. How many 5 rupee coins and 1 rupee coins will you usef 2x20
change is not possible then display -1.
Sample Input
Expected Output
Available Available Amount to
coins
Rs. 1 coins Rs. 5 notes be made
needed
Rs. 5
moters
needed
<
2.
LON
Answers
Answer:
plz mark branlist answer
def make_amount(rupees_to_make,no_of_five,no_of_one):
five_needed=0
one_needed=0
if((5*no_of_five+no_of_one)>=rupees_to_make):
if((5*no_of_five+no_of_one)==rupees_to_make):
five_needed=no_of_five
one_needed=no_of_one
print("No. of Five needed :",five_needed)
print("No. of One needed :",one_needed)
elif((5*no_of_five+no_of_one)>rupees_to_make):
temp_five_needed = rupees_to_make//5
if(no_of_five>=temp_five_needed):
five_needed=temp_five_needed
elif(no_of_five<temp_five_needed):
five_needed=no_of_five
temp_one_needed = rupees_to_make-(5*five_needed)
if(no_of_one>=temp_one_needed and (temp_one_needed+(5*five_needed))==rupees_to_make):
print("No. of Five needed :",five_needed)
print("No. of One needed :",temp_one_needed)
else:
print(-1)
else:
print(-1)
rupees_to_make=93
no_of_five=19
no_of_one=2
make_amount(rupees_to_make, no_of_five, no_of_one)