(Use the bookmarklet on this post to see the code with APL font and syntax highlighting.)

Not very fast (O(2^n) where n is the length of the input array), but definitely gets the job done, concisely. Demo is here. Note that an array of ones (e.g. [1, 1, 1, 1]) is a corner case, because the answer is one higher than the sum of the input numbers.

Explanation:

solve←{⊃(⍳1++/⍵)~⊃(+,,)/⍵}
{...} ⍝ Define a function
⊃(...)/⍵ ⍝ Reduce the input by...
+,, ⍝ concatenation of both sides and
⍝ pairwise sum
~ ⍝ Remove the numbers in the above from
(⍳1++/⍵) ⍝ Generate 1..(sum of ⍵ + 1)
⊃ ⍝ Take the first (smallest) number

For further actions, you may consider blocking this person and/or reporting abuse

We're a place where coders share, stay up-to-date and grow their careers.

APL (using Dyalog APL):

(Use the bookmarklet on this post to see the code with APL font and syntax highlighting.)

Not very fast (

`O(2^n)`

where`n`

is the length of the input array), but definitely gets the job done, concisely. Demo is here. Note that an array of ones (e.g.`[1, 1, 1, 1]`

) is a corner case, because the answer is one higher than the sum of the input numbers.Explanation: