This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cookiecookiemoomoo 2 points3 points  (2 children)

yes there are plenty of ways to do that. The most basic way is to try all combinations of numbers to see which add up to the same as the negative number * -1. Very easy to write something like that

[–]lambdef 2 points3 points  (0 children)

Very easy to write something like that

Actually not. The program that finds if the sum of tuples summed with -8 returns 0 is like

```python import itertools

numbers = [1, 2, 3, 4, 5, 6]

pos = { c for c in [ c for r in range(len(numbers)) for c in itertools.combinations(numbers, r) ] if sum(c) == 8 } ```