If sum_so_far equals to given sum then return 1 else 0
if sum_so_far == Sum : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT return 0 NEW_LINE DEDENT ans = dp [ i ] [ tight ] [ sum_so_far ] NEW_LINE if ans != - 1 : NEW_LINE return ans NEW_LINE ans = 0 NEW_LINE for currdigit in range ( 0 , 10 ) : NEW_LINE currdigitstr = str ( currdigit ) NEW_LINE