You are given an array of `n+1` integers `1` through `n`. In addition there is a single duplicate integer.

The array is unsorted.

An example valid array would be `[3, 2, 5, 1, 3, 4]`. It has the integers `1` through `5` and `3` is duplicated. `[1, 2, 4, 5, 5]` would not be valid as it is missing `3`.

You should return the duplicate value as a single integer.

Difficulty: introductory

Starter code:

def find_dup(arr):
	

Solutions:
def find_dup(arr):
    return sum(arr) - len(arr)*(len(arr)-1)/2
    #your code here


def find_dup(arr):
    return max([i for i in arr if arr.count(i) > 1])

from collections import Counter
find_dup = lambda xs: Counter(xs).most_common(1)[0][0]

def find_dup(arr):
    return sum(arr) - len(arr) * (len(arr) - 1) // 2

def find_dup(arr):
    return sum(arr) - sum(range(len(arr)))

find_dup = lambda l: [v for i, v in enumerate(l) if l.index(v) != i][0]


def find_dup(arr):
    for i in range(1, len(arr)):
        for j in range(i):
            if arr[i] == arr[j]:
                return arr[i]    
    return None

def find_dup(arr):
    return sum(arr) - (len(arr) - 1) * len(arr) // 2

def find_dup(arr):
    return next(n for n in arr if arr.count(n) == 2)