Ways to pay an amount
You have an unlimited supply of coins of each value in coins. Return how many different combinations of coins add up to exactly amount. A combination is defined by how many coins of each value it uses, not by their order: with [1, 2], paying 1 + 1 + 2 and 2 + 1 + 1 is the same combination. An amount of 0 has exactly one combination, the empty one.
coins holds 1 to 50 distinct positive integers and amount goes from 0 to 2,000. Aim for O(len(coins) · amount) time.
Besides the tests, one large input (an amount of 150) with a ~200 ms limit (scaled to your device's speed): brute force won't pass.
Examples
ways_to_pay([1,2], 4)→3ways_to_pay([5,2,3], 10)→4ways_to_pay([4,6], 7)→0