Your task is to find the first element of an array that is not consecutive.

By not consecutive we mean not exactly 1 larger than the previous element of the array.

E.g. If we have an array `[1,2,3,4,6,7,8]` then `1` then `2` then `3` then `4` are all consecutive but `6` is not, so that's the first non-consecutive number.

```if:c
If a non consecutive number is found then return `true` and set the passed in pointer to the number found.

If the whole array is consecutive then return `false`.
```
```if-not:c
If the whole array is consecutive then return `null`^(2).
```
The array will always have at least `2` elements^(1) and all elements will be numbers. The numbers will also all be unique and in ascending order. The numbers could be positive or negative and the first non-consecutive could be either too!

If you like this Kata, maybe try this one next: https://www.codewars.com/kata/represent-array-of-numbers-as-ranges

```if:c
^(1) Can you write a solution that will return `false` for both `[]` and `[ x ]` (an empty array and one with a single number) though? (This is an empty array and one with a single number and is not tested for, but you can write your own example test. )
```
```if-not:c
^(1) Can you write a solution that will return `null`^(2) for both `[]` and `[ x ]` though?  (This is an empty array and one with a single number and is not tested for, but you can write your own example test. )

^(2)  
Swift, Ruby and Crystal: `nil`  
Haskell: `Nothing`  
Python, Rust: `None`  
Julia: `nothing`  
Nim: `none(int)` (See [options](https://nim-lang.org/docs/options.html))
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def first_non_consecutive(arr):
	

Solutions:
def first_non_consecutive(arr):
	if not arr:
		return 0
	for (i, x) in enumerate(arr[:-1]):
		if x + 1 != arr[i + 1]:
			return arr[i + 1]


def first_non_consecutive(a):
	i = a[0]
	for e in a:
		if e != i:
			return e
		i += 1
	return None


def first_non_consecutive(arr):
	for i in range(1, len(arr)):
		if arr[i] - arr[i - 1] > 1:
			return arr[i]


def first_non_consecutive(arr):
	return next((j for (i, j) in zip(arr, arr[1:]) if i + 1 != j), None)


def first_non_consecutive(arr):
	for (i, v) in enumerate(arr, arr[0]):
		if v != i:
			return v


def first_non_consecutive(arr):
	for b in range(len(arr) - 1):
		if arr[b + 1] - arr[b] != 1:
			return arr[b + 1]


def first_non_consecutive(arr):
	init = arr[0]
	for i in arr:
		if init != i:
			return i
		else:
			init += 1
	return None


def first_non_consecutive(arr):
	pre = arr[0] - 1
	for e in arr:
		if e - pre != 1:
			return e
		pre = e
	return


def first_non_consecutive(a):
	return [e for (i, e) in enumerate(a + [None]) if e != a[0] + i][0]


def first_non_consecutive(arr):
	a = [x + 1 for x in range(min(arr), max(arr) + 1) if x not in arr]
	return None if a == [] else a[0]


def first_non_consecutive(arr):
	for x in range(min(arr), max(arr) + 1):
		if x not in arr:
			return x + 1


def first_non_consecutive(arr):
	for n in range(len(arr) - 1):
		if arr[n + 1] != arr[n] + 1:
			return arr[n + 1]
	return None


def first_non_consecutive(arr):
	for (i, q) in enumerate(arr, arr[0]):
		if i != q:
			return q


def first_non_consecutive(arr):
	b = arr.pop(0)
	for i in arr:
		if b + 1 == i:
			b = i
		else:
			return i


def first_non_consecutive(arr):
	for index in range(len(arr) - 1):
		if abs(arr[index + 1] - arr[index]) != 1:
			return arr[index + 1]
	return None


def first_non_consecutive(a):
	for (i, x) in enumerate(a, a[0]):
		if i != x:
			return x


def first_non_consecutive(arr):
	for ind in range(1, len(arr)):
		if arr[ind] - arr[ind - 1] > 1:
			return arr[ind]


def first_non_consecutive(list):
	tmp = ''
	for item in list:
		if tmp == '':
			tmp = str(item)
		elif item == int(tmp) + 1:
			tmp = str(item)
		else:
			return item


def first_non_consecutive(arr):
	k = arr[0]
	for i in arr:
		if i != k:
			return i
		k += 1
	return None


def first_non_consecutive(arr):
	for i in range(1, len(arr)):
		if arr[i] - arr[i - 1] != 1:
			return arr[i]
	else:
		return None


def first_non_consecutive(arr):
	for x in range(1, len(arr)):
		if arr[x] - 1 != arr[x - 1]:
			return arr[x]


def first_non_consecutive(arr):
	for (i, a) in enumerate(arr):
		if 0 < i < len(arr) + 1 and a != arr[i - 1] + 1:
			return a


first_non_consecutive = lambda a: min([e for (i, e) in enumerate(a) if i > 0 and e != a[i - 1] + 1] or [None])


def first_non_consecutive(arr):
	for j in range(1, len(arr)):
		if arr[j] != arr[j - 1] + 1:
			return arr[j]


from itertools import count

def first_non_consecutive(arr):
	return next((a for (a, b) in zip(arr, count(arr[0])) if a != b), None)


def first_non_consecutive(arr):
	return next(iter((a for (a, b) in zip(arr, range(arr[0], arr[-1])) if a != b)), None)


def first_non_consecutive(arr):
	for ix in range(len(arr) - 1):
		if arr[ix] + 1 != arr[ix + 1]:
			return arr[ix + 1]


def first_non_consecutive(arr):
	expected = arr[0]
	for x in arr:
		if x != expected:
			return x
		else:
			expected = x + 1


def first_non_consecutive(a):
	i = 0
	n = None
	while i < len(a) - 1:
		if a[i] + 1 != a[i + 1]:
			n = a[i + 1]
			break
		i += 1
	return n


def first_non_consecutive(arr):
	for (number_lag, number) in zip(arr[:-1], arr[1:]):
		if number_lag + 1 != number:
			return number
	else:
		return None


def checkConsecutive(l):
	return sorted(l) == list(range(min(l), max(l) + 1))

def first_non_consecutive(nums):
	if checkConsecutive(nums):
		return None
	else:
		gaps = [[s, e] for (s, e) in zip(nums, nums[1:]) if s + 1 < e]
		edges = iter(nums[:1] + sum(gaps, []) + nums[-1:])
		A = list(zip(edges, edges))
		A.pop(0)
		L = []
		for i in A:
			for j in i:
				L.append(j)
		return L[0]


def first_non_consecutive(arr):
	length = len(arr)
	if length <= 2:
		return None
	len_list = list(range(length))
	for item in len_list:
		try:
			if abs(arr[item + 1] - arr[item]) != 1:
				return arr[item + 1]
				break
		except:
			return None


def first_non_consecutive(arr):
	for n in arr:
		if n != arr.index(n) + arr[0]:
			return n


def first_non_consecutive(arr):
	return next((n for (i, n) in enumerate(arr[1:]) if n != arr[i] + 1), None)


def first_non_consecutive(arr):
	is_consecutive = True
	for (index, item) in enumerate(arr[0:-1]):
		if item + 1 == arr[index + 1]:
			continue
		else:
			is_consecutive = False
			return arr[index + 1]
			break
	if is_consecutive == True:
		return None


from typing import List, Optional

def first_non_consecutive(arr: List[int]) -> Optional[int]:
	for (prev, next) in zip(arr, arr[1:]):
		if next - prev > 1:
			return next


def first_non_consecutive(arr):
	return None if len(arr) < 2 else arr[1] if arr[1] - arr[0] != 1 else first_non_consecutive(arr[1:])


from operator import eq
from itertools import compress

def first_non_consecutive(a):
	return next(compress(a, [not eq(*x) for x in zip(a, list(range(a[0], a[0] + len(a) + 1)))]), None)


def first_non_consecutive(arr):
	return next((y for (x, y) in zip(arr, arr[1:]) if y - x > 1), None)


def first_non_consecutive(arr):
	return next((i for i in arr if not min(arr) + arr.index(i) == i), None)


def first_non_consecutive(arr):
	try:
		return [i for i in arr if not min(arr) + arr.index(i) == i][0]
	except:
		return None


def first_non_consecutive(lst_input):
	if sorted(lst_input) == list(range(min(lst_input), max(lst_input) + 1)):
		return None
	elif sorted(lst_input) != list(range(min(lst_input), max(lst_input) + 1)):
		for (val, val2) in zip(sorted(lst_input), list(range(min(lst_input), max(lst_input) + 1))):
			if val != val2:
				return val


def first_non_consecutive(arr):
	for i in range(len(arr) - 1):
		if arr[i + 1] - arr[i] != 1:
			return arr[i + 1]
		else:
			print('', end='')


def first_non_consecutive(arr):
	numbers = list(range(arr[0], arr[-1] + 1))
	missing = [number for number in numbers if number not in arr]
	return missing[0] + 1 if missing != [] else None


def first_non_consecutive(x):
	for i in x:
		if i - 1 not in x:
			if i == x[0]:
				pass
			else:
				return i


def first_non_consecutive(arr):
	for (i, e) in enumerate(arr):
		if i == len(arr) - 1:
			return None
		elif e + 1 != arr[i + 1]:
			return arr[i + 1]


def first_non_consecutive(arr):
	a = [arr[i + 1] for i in range(len(arr)) if i + 1 < len(arr) and arr[i + 1] - arr[i] > 1]
	print(a)
	return a[0] if len(a) > 0 else None


def first_non_consecutive(arr):
	d = [arr[0]]
	for i in arr:
		d.append(i + 1)
	if len(list(set(d[:-1]).difference(arr))) == 0:
		return None
	else:
		return min(list(set(d[:-1]).difference(arr))) + 1


def first_non_consecutive(arr):
	results = set(range(arr[0], arr[-1])) - set(arr)
	return min(results) + 1 if len(results) > 0 else None


def first_non_consecutive(arr):
	comparator = arr[0]
	for n in arr:
		if comparator == n:
			comparator = comparator + 1
		else:
			return n


def first_non_consecutive(arr):
	n = 0
	while n < len(arr) - 1:
		if arr[n + 1] - arr[n] != 1:
			return arr[n + 1]
		n += 1


def first_non_consecutive(arr):
	result = arr[0]
	for i in arr[1:]:
		if i - result != 1:
			return i
		result = i


def first_non_consecutive(arr):
	new_list = arr.pop(0)
	for num in arr:
		new_list += 1
		if num != new_list:
			return num


def first_non_consecutive(arr):
	for int in range(1, len(arr)):
		if arr[int] - arr[int - 1] != 1:
			return arr[int]
	return None


def first_non_consecutive(l):
	for (i, n) in enumerate(l[1:]):
		if n != l[i] + 1:
			return n


def first_non_consecutive(arr):
	for (i, x) in enumerate(arr):
		if x != arr[i - 1] + 1 and i > 0:
			return x
	return None


def first_non_consecutive(arr):
	i = arr.pop(0)
	for item in arr:
		i += 1
		if item != i:
			return item
	return None


def first_non_consecutive(arr):
	i = 0
	for num in range(arr[0], arr[len(arr) - 1]):
		if num != arr[i]:
			return arr[i]
		i += 1
	return None


def first_non_consecutive(arr):
	(first, last) = (arr[0], arr[-1])
	diff = set(range(first, last + 1)) - set(arr)
	return min(diff) + 1 if diff else None


def first_non_consecutive(arr):
	x = len(arr)
	z = []
	y = []
	for k in range(0, x - 1):
		if arr[k] + 1 == arr[k + 1]:
			y.append(arr[k + 1])
		else:
			z.append(arr[k + 1])
	if z == []:
		return None
	else:
		z = min(z)
		return z


def first_non_consecutive(arr):
	size = len(arr)
	for i in range(size):
		if i == size - 1:
			return None
		elif arr[i + 1] > arr[i] + 1:
			return arr[i + 1]


def first_non_consecutive(arr):
	n = 0
	try:
		for i in arr:
			if i + 1 == arr[n + 1]:
				n += 1
				continue
			elif i + 1 != arr[n + 1]:
				return arr[n + 1]
	except:
		return None


def first_non_consecutive(arr):
	i = 0
	while i < len(arr) - 1:
		i += 1
		if arr[0] >= 0 and arr[i] - arr[i - 1] != 1:
			return arr[i]
			break
		elif arr[0] < 0 and abs(arr[i - 1]) - abs(arr[i]) != 1:
			return arr[i]
			break
	else:
		return None


def first_non_consecutive(arr):
	lena = len(arr)
	b = arr[0]
	for i in arr:
		if b == i:
			b = b + 1
			print('tut')
		else:
			return i


def first_non_consecutive(arr):
	for (i, v) in enumerate(arr, arr[0]):
		if i != v:
			return i + 1
	return None


def first_non_consecutive(a):
	temp = [a[i] for i in range(len(a)) if i != 0 and a[i] != a[i - 1] + 1]
	return temp[0] if temp else None


def first_non_consecutive(arr):
	first_ele = arr[0]
	for i in range(1, len(arr)):
		if arr[i] == first_ele + 1:
			first_ele = first_ele + 1
		else:
			return arr[i]


def first_non_consecutive(arr):
	i = 0
	j = 1
	for k in range(len(arr) - 1):
		if arr[i] + 1 != arr[j]:
			return arr[j]
		else:
			i += 1
			j += 1


first_non_consecutive = lambda arr: (lambda x: None if len(x) == 0 else min(x) + 1)({*range(min(arr), max(arr) + 1)}.difference({*arr}))


def first_non_consecutive(arr):
	for el in range(0, len(arr) - 1):
		if arr[el + 1] - arr[el] > 1:
			return arr[el + 1]


import numpy

def first_non_consecutive(arr):
	if sorted(arr) == list(range(min(arr), max(arr) + 1)):
		return None
	else:
		difference = list(numpy.diff(arr))
		for i in difference:
			if i > 1:
				index = difference.index(i)
				return arr[index + 1]


def first_non_consecutive(arr):
	if len(arr) == 2:
		return None
	elem_1 = arr[0]
	elem_2 = arr[1]
	elem_3 = arr[2]
	diff_1 = elem_2 - elem_1
	diff_2 = elem_3 - elem_2
	if diff_1 > diff_2:
		grade_1 = diff_2
	elif diff_1 < diff_2:
		grade_1 = diff_1
	else:
		grade_1 = diff_1
	for i in range(0, len(arr) - 1):
		if arr[i + 1] != arr[i] + grade_1:
			return arr[i + 1]
	return None


def first_non_consecutive(arr):
	for (a, b) in zip(arr[:-1], arr[1:]):
		if b != a + 1:
			return b


def first_non_consecutive(arr):
	x = arr[0]
	for index in arr:
		if index != x:
			result = index
			break
		x += 1
	else:
		result = None
	return result


def first_non_consecutive(arr):
	try:
		for i in range(len(arr)):
			if arr[i] != arr[i + 1] - 1:
				return arr[i + 1]
	except:
		return None


def first_non_consecutive(arr):
	for num in arr:
		i = arr.index(num)
		if i > len(arr) - 2:
			return None
		elif arr[i + 1] == int(num + 1):
			continue
		else:
			return arr[i + 1]