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

Difficulty: introductory

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): #define the function
    start = 0 #This is a variable which will detect if the number is the first in the list. In that case it won't have a preceding number to be consecutive to it
    answer = [] #empty list for later use. This will be the list which will contain the answer, i.e, where we will append the non consecutive entries
    for number in arr: #for loop goes through each entry in the list because we want to check the non consecutive numbers in it
        if start == 0: #as mentioned before start is a variable set to check if the number presented is the first in the list. If yes, it satisfies the equation
            current = number #current is a variable which is used to take the number as current after all processes so we can check if the next number is 1 extra than it
            start = 1 #changes start to 1 so we know that next values aren't first in the list and this never satisfies the if loop after this
            continue #goes to the start of the start of the loop because it the first number doesn't need to go further
        elif number != current + 1: #we ignore the consecutive numbers and if the number in the loop right now is not one more than the previous one, this situation is triggered
            format = {'i' : arr.index(number), 'n' : number} #format is a dictionary which assigns the items and numbers in a format the program wants
            answer.append(format) #we append the dictionary in the list which will give the answer because the answer needs to be in a list form
        current = number #same as used before
    return answer #we done and dusted and return finishes the process. YAY!


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):
    return [{'i':i, 'n':n} for i,n in enumerate(arr[1:], 1) if arr[i-1] != n - 1 ]

def all_non_consecutive(arr):
    return [ {'n':e, 'i':i} for i,e in enumerate(arr[1:],1) if e - arr[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]