dynamic make change algorithm