the remainder ghccannot be divided by so we try the ghc denomination and realize that we can multiply it by to obtain ghc at the end of the daythe least possible number of denominations to create ghc is to get one ghc and four ghc notes so farour greedy algorithm seems to be doing pretty well function that returns the respective denominations is as followsdef basic_small_change(denomtotal_amount)sorted_denominations sorted(denomreverse=truenumber_of_denoms [for in sorted_denominationsdiv total_amount total_amount total_amount if div number_of_denoms append((idiv)return number_of_denoms this greedy algorithm always starts by using the largest denomination possible denom is list of denominations sorted(denomreverse=truewill sort the list in reverse so that we can obtain the largest denomination at index nowstarting from index of the sorted list of denominationssorted_denominationswe iterate and apply the greedy techniquefor in sorted_denominationsdiv total_amount total_amount total_amount if div number_of_denoms append((idiv)the loop will run through the list of denominations each time the loop runsit obtains the quotientdivby dividing the total_amount by the current denominationi total_amount is updated to store the remainder for further processing if the quotient is greater than we store it in number_of_denoms unfortunatelythere are instances where our algorithm fails for instancewhen passed ghsour algorithm returns one ghc and four ghs this output ishowevernot the optimal solution the right solution will be to use two ghc and two ghc denominations