Minimize coins required to obtain all possible values up to N | Function to find minimum count of { 1 , 2 , 5 } valued coins required to make a change of all values in the range [ 1 , N ] ; Number of 5 valueds coins required ; Number of 1 valued coins required ; Number of 2 valued coins required ; Driver Code
def find ( N ) : NEW_LINE INDENT F = int ( ( N - 4 ) / 5 ) NEW_LINE if ( ( N - 5 * F ) % 2 ) == 0 : NEW_LINE INDENT O = 2 NEW_LINE DEDENT else : NEW_LINE INDENT O = 1 NEW_LINE DEDENT T = ( N - 5 * F - O ) // 2 NEW_LINE print ( " Count ▁ of ▁ 5 ▁ valueds ▁ coins : ▁ " , F ) NEW_LINE print ( " Count ▁ of ▁ 2 ▁ valueds ▁ coins : ▁ " , T ) NEW_LINE print ( " Count ▁ of ▁ 1 ▁ valueds ▁ coins : ▁ " , O ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 8 NEW_LINE find ( N ) NEW_LINE DEDENT