Smallest number you can get by adding up numbers in sequence [closed]

You a sequence of numbers like this one given to you as a string:

"1 2 3 4 8 11 19 33 59 154 196 260"

Create a program (any language) that calculates the smallest outcome you can't get by adding two of those numbers together.

The numbers given must be integers, and are always positive.

You can only use each number once.

The answer must be > 0 and a whole number. The given string must contain at least a 1.

Examples of invalid outcomes:

"1 2 3 4 8 11 19 33 59 154 196 260"

• 3 (1 + 2)
• 54 (19 + 33 + 8 + 2)

Example of valid outcome:

"1 2 7 34 34 78"

• 4 (1 + 2 = 3, can't get 4 by adding any numbers.)

The shortest answer wins, answers can be submitted until october 30th, 18:00 CET.

closed as unclear what you're asking by Martin Ender, Beta Decay, hmatt1, COTO, NinjaBearMonkeyOct 26 '14 at 19:15

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• I think this would be much much better suited for code golf as there is not much in this task that asks for out-of-the-box solutions. If you change this to code golf, you should consider imposing restrictions to avoid solutions like return min(set(range(sum(Input)))-map(sum(Combinations,Input))). – Wrzlprmft Oct 26 '14 at 17:52
• This is horribly vague... You need a more detailed spec. – Beta Decay Oct 26 '14 at 17:57
• @KlaasSchoenmaker That's a contradiction with the spec, where you've written "You can only use each number once.". It's also inconsistent with your last example. – Martin Ender Oct 26 '14 at 18:13
• Isn't the answer always 1? It's larger than 0 and can't be the sum of two (strictly) positive integers. – Falko Oct 26 '14 at 18:46
• The second paragraph states "...can't get by adding any two of those numbers together", but subsequent examples clearly show 3+ numbers being summed together to obtain "invalid" outcomes. – COTO Oct 26 '14 at 18:47

Python - 104 99

My interpretation:

L=map(int,input().split())
k=1
while k in map(sum,[[i,j]for i in L for j in L if i<j]):k+=1
print k

I tested it with the input string 0 1 2 3 4 8 11 19 33 59 154 196 260 containing a 0 to avoid the trivial solution 0.

Result:

16
• lol +1 for "my interpretation". Pretty much summarizes the whole thing, doesn't it. ;) – COTO Oct 26 '14 at 23:11