Combination sum

Write combination_sum(candidates, target) that returns every combination of the distinct positive candidates that adds up to target, where each candidate may be used any number of times. Each combination is a list in non-decreasing order, and no combination appears twice. Order of the results does not matter.

combination_sum([2, 3, 6, 7], 7)  ->  [[2, 2, 3], [7]]
combination_sum([2, 3, 5], 8)     ->  [[2, 2, 2, 2], [2, 3, 3], [3, 5]]
combination_sum([2], 1)           ->  []

The point is to practise pruning and the start index that stops the same combination appearing in different orders.

def combination_sum(candidates, target):
    ...