test cases do you want to enter your denominations yn n enter the change you want to make in indian currency 987 following is minimal change for 987 500 100 100 100 100 50 20 10 5 2 do you want to enter your denominations yn y enter number of denomination 10 1 5 10 20 50 100 200 500 1000 2000 enter the change you want to make 18745 following is minimal change for 18745 2000 2000 2000 2000 2000 2000 2000 2000 2000 500 200 20 20 5 do you want to enter your denominations yn n enter the change you want to make 0 the total value cannot be zero or negative do you want to enter your denominations yn n enter the change you want to make 98 the total value cannot be zero or negative do you want to enter your denominations yn y enter number of denomination 5 1 5 100 500 1000 enter the change you want to make 456 following is minimal change for 456 100 100 100 100 5 5 5 5 5 5 5 5 5 5 5 1 find the minimum change from the given denominations and value findminimumchange1 5 10 20 50 100 200 500 1000 2000 18745 2000 2000 2000 2000 2000 2000 2000 2000 2000 500 200 20 20 5 findminimumchange1 2 5 10 20 50 100 500 2000 987 500 100 100 100 100 50 20 10 5 2 findminimumchange1 2 5 10 20 50 100 500 2000 0 findminimumchange1 2 5 10 20 50 100 500 2000 98 findminimumchange1 5 100 500 1000 456 100 100 100 100 5 5 5 5 5 5 5 5 5 5 5 1 initialize result traverse through all denomination find denominations driver code all denominations of indian currency if user does not enter print result find the minimum change from the given denominations and value find_minimum_change 1 5 10 20 50 100 200 500 1000 2000 18745 2000 2000 2000 2000 2000 2000 2000 2000 2000 500 200 20 20 5 find_minimum_change 1 2 5 10 20 50 100 500 2000 987 500 100 100 100 100 50 20 10 5 2 find_minimum_change 1 2 5 10 20 50 100 500 2000 0 find_minimum_change 1 2 5 10 20 50 100 500 2000 98 find_minimum_change 1 5 100 500 1000 456 100 100 100 100 5 5 5 5 5 5 5 5 5 5 5 1 initialize result traverse through all denomination find denominations append the answers array driver code all denominations of indian currency if user does not enter print result
def find_minimum_change(denominations: list[int], value: str) -> list[int]:
    
    total_value = int(value)

    
    answer = []

    
    for denomination in reversed(denominations):
        
        while int(total_value) >= int(denomination):
            total_value -= int(denomination)
            answer.append(denomination)  

    return answer



if __name__ == "__main__":
    denominations = []
    value = "0"

    if (
        input("Do you want to enter your denominations ? (yY/n): ").strip().lower()
        == "y"
    ):
        n = int(input("Enter the number of denominations you want to add: ").strip())

        for i in range(n):
            denominations.append(int(input(f"Denomination {i}: ").strip()))
        value = input("Enter the change you want to make in Indian Currency: ").strip()
    else:
        
        denominations = [1, 2, 5, 10, 20, 50, 100, 500, 2000]
        value = input("Enter the change you want to make: ").strip()

    if int(value) == 0 or int(value) < 0:
        print("The total value cannot be zero or negative.")

    else:
        print(f"Following is minimal change for {value}: ")
        answer = find_minimum_change(denominations, value)
        
        for i in range(len(answer)):
            print(answer[i], end=" ")