Algorithm to determine coin combinations

后端 未结 13 2542
臣服心动
臣服心动 2020-12-25 08:33

I was recently faced with a prompt for a programming algorithm that I had no idea what to do for. I\'ve never really written an algorithm before, so I\'m kind of a newb at t

相关标签:
13条回答
  • 2020-12-25 09:09

    Another Python version:

    def change(coins, money):
        return (
            change(coins[:-1], money) +
            change(coins, money - coins[-1])
            if money > 0 and coins
            else money == 0
        )
    
    0 讨论(0)
提交回复
热议问题