Given an array of integers, find the one that appears an odd number of times.

There will always be only one integer that appears an odd number of times.

Difficulty: introductory

Starter code:

def find_it(seq):
	

Solutions:
def find_it(seq):
    for i in seq:
        if seq.count(i)%2!=0:
            return i

def find_it(seq):
    counts = dict()
    for n in seq:
        if n not in counts:
            counts[n] = 0
        
        counts[n] += 1
        
    for n, n_count in list(counts.items()):
        if n_count % 2 != 0:
            return n


def find_it(seq):
    for n in set(seq):
        if seq.count(n) % 2 != 0: return n


def find_it(seq):
    return [x for x in seq if seq.count(x) % 2][0]


from collections import Counter
def find_it(l):
    return [k for k, v in Counter(l).items() if v % 2 != 0][0]

def find_it(seq):
    nums = set()
    for num in seq:
        if num in nums:
            nums.remove(num)
        else:
            nums.add(num)
    return nums.pop()


def find_it(seq):
    for elem in set(seq):
        if seq.count(elem) % 2 == 1:
            return elem


def find_it(seq):
    result = 0
    for x in seq:
        result ^= x
    return result


def find_it(seq):
    return [x for x in set(seq) if seq.count(x) % 2][0]

from itertools import groupby

def find_it(seq):
    return next(k for k, g in groupby(sorted(seq)) if len(list(g)) % 2)