An array is called `centered-N` if some `consecutive sequence` of elements of the array sum to `N` and this sequence is preceded and followed by the same number of elements. 

Example:
```
[3,2,10,4,1,6,9] is centered-15
because the sequence 10,4,1 sums to 15 and the sequence 
is preceded by two elements [3,2] and followed by two elements [6,9]

```

Write a method called `isCenteredN` that returns :

- `true` if its array argument is `not empty` and `centered-N` or empty and centered-0
- otherwise returns `false`.

Difficulty: introductory

Starter code:

def is_centered(arr,n):
	

Solutions:
def is_centered(arr,n):
    l = int(len(arr)/2) if len(arr)%2==0 else int((len(arr)-1)/2)
    return any(sum(arr[i:-i])==n for i in range(1, l+1)) or sum(arr)==n

from itertools import accumulate

def is_centered(arr, n):
    xs = [0] + list(accumulate(arr))
    return any(b-a==n for a, b in zip(xs[:len(arr)//2+1], xs[::-1]))

def is_centered(arr,n):
    while True:
        if sum(arr) == n: return True
        try: (arr.pop(), arr.pop(0))
        except IndexError: return False

def is_centered(arr,n):
    if sum(arr) == n: return True
    for i in range(1,int(len(arr)/2)+1):        
        if sum(arr[i:-i]) == n:
            return True
    return False

def is_centered(arr, n):
    x = sum(arr)
    if x == n: return True
    for i in range(len(arr)>>1):
        x -= arr[i] + arr[-i-1]
        if x == n: return True
    return False

def is_centered(arr,n):
    for i in range(len(arr)//2+1):
        if sum(arr[i:len(arr)-i])==n:
            return True
    return False

def is_centered(a, n):
    if not n and not len(a) % 2: return 1
    for i in range(sum(divmod(len(a), 2)) - 1, -1, -1):
        if sum(a[i:len(a)-i]) == n:
            return 1
    return 0

def is_centered(arr,n):
    return any(
        sum(arr[i:len(arr)-i]) == n for i in range(len(arr)//2 + 1)
    )


def is_centered(arr,n):
    for i in range(len(arr)):
        for j in range(len(arr)+1):
            if j>i:
                if sum(arr[i:j]) == n and i == len(arr)-j:
                    return True
    return True if n==0 and arr!=arr[::-1] else False

def is_centered(arr, n):
    if (len(arr) % 2 == 0) and n == 0:
        return True
    left, right = (len(arr) // 2, len(arr) // 2) if len(arr) % 2 else (len(arr) // 2 - 1, len(arr) // 2)
    while left >= 0 and right <= len(arr):
        if sum(arr[left:right + 1]) == n:
            return True
        left -= 1
        right += 1
    return False