Combinations that add up to a number - Julia lang
问题 I'm new to Julia. Is there a way to add up elements from a list that add up to a certain value target? I have done this with Python's itertools library like in the example below but I find it extremely slow for larger datasets. import itertools numbers = [1, 2, 3, 7, 7, 9, 10] result = [seq for i in range(len(numbers), 0, -1) for seq in itertools.combinations(numbers, i) if sum(seq) == 10] print result 回答1: While like mentioned by Kermit the problem is NP-hard, it is still worth knowing how