def getChange(amount, curr, left): if sum(curr) == amount: return curr else: for i, x in enumerate(left): getChange(amount, curr + list(x), left[:i]+left[i:])