In celebration of Epiphany, a holiday known for the exchange of gifts, imagine you have a set of gift tokens with different values. Your task is to find out how many different combinations of these tokens can sum up to a given target value. You have an infinite supply of each token.
tokens
, where each integer represents the value of a gift token.target
which is the total value you need to achieve using combinations of tokens.target
value. Two combinations are considered unique if they have a different count of at least one type of token.For instance, if tokens = [1, 2, 3]
and target = 4
, some possible combinations are:
Thus, the function should return 4
.
1 + 3
is the same as 3 + 1
).Happy coding, and enjoy the spirit of gift-giving this Epiphany!
Below is some starter code in multiple languages. Complete the function to solve the problem.