My function returns 1 for [-1, 1] - unless I'm missing something that is the correct answer.
The function will never return the first number. The first number starts the sequence, it can't be non-consecutive in that case. The second number should be 0 but it's -1 so that is the first non-consectuive number.
Ah, coercion. Thanks for pointing it out - I refactored it.
Care to explain your reasoning?
My function returns 1 for [-1, 1] - unless I'm missing something that is the correct answer.
The function will never return the first number. The first number starts the sequence, it can't be non-consecutive in that case. The second number should be 0 but it's -1 so that is the first non-consectuive number.