Your task is to find all the elements of an array that are non consecutive.

A number is non consecutive if it is not exactly one larger than the previous element in the array. The first element gets a pass and is never considered non consecutive.

~~~if:javascript,haskell,swift
Create a function named `allNonConsecutive`
~~~
~~~if:python,rust
Create a function name `all_non_consecutive`
~~~

E.g., if we have an array `[1,2,3,4,6,7,8,15,16]` then `6` and `15` are non-consecutive.

~~~if:javascript,python
You should return the results as an array of objects with two values `i: ` and `n: `.
~~~
~~~if:haskell,swift,rust
You should return the results as an array of tuples with two values: the index of the non-consecutive number and the non-consecutive number.
~~~

E.g., for the above array the result should be:
```python
[
  {'i': 4, 'n': 6},
  {'i': 7, 'n': 15}
]
```

If the whole array is consecutive or has one element then return an empty array.

The array elements will all be numbers. The numbers will also all be unique and in ascending order. The numbers could be positive and/or negetive and the gap could be larger than one.

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

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def all_non_consecutive(arr):
	

Solutions:
def all_non_consecutive(a):
	return [{'i': i, 'n': y} for (i, (x, y)) in enumerate(zip(a, a[1:]), 1) if x != y - 1]


def all_non_consecutive(arr):
	answer = []
	for i in range(len(arr) - 1):
		if arr[i + 1] - arr[i] != 1:
			answer.append({'i': i + 1, 'n': arr[i + 1]})
	return answer


def all_non_consecutive(arr):
	return [{'i': i + 1, 'n': b} for (i, (a, b)) in enumerate(zip(arr, arr[1:])) if b - a != 1]


def all_non_consecutive(arr):
	return [{'i': i + 1, 'n': n} for (i, n) in enumerate(arr[1:]) if arr[i + 1] - arr[i] != 1]


def all_non_consecutive(arr):
	start = 0
	answer = []
	for number in arr:
		if start == 0:
			current = number
			start = 1
			continue
		elif number != current + 1:
			format = {'i': arr.index(number), 'n': number}
			answer.append(format)
		current = number
	return answer


def all_non_consecutive(lst):
	return [{'i': i, 'n': n} for (i, n) in enumerate(lst[1:], 1) if n != lst[i - 1] + 1]


def all_non_consecutive(arr):
	oldobj = 0
	thelist = []
	for (obj, num) in zip(arr, range(0, 1000)):
		if oldobj + 1 < obj and num != 0:
			thelist.append({'i': num, 'n': obj})
		oldobj = obj
	return thelist


from itertools import islice

def all_non_consecutive(arr):
	return [{'i': c, 'n': b} for (c, (a, b)) in enumerate(zip(arr, islice(arr, 1, None)), 1) if a + 1 != b]