1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-24 01:31:56 +01:00
CodeWars/6kyu/find_the_unique_number/solution.py
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

16 lines
274 B
Python

def find_uniq(arr):
a = arr[0]
count_a = 1
b = None
count_b = 0
for e in arr[1:]:
if e != a:
count_b += 1
b = e
else:
count_a += 1
if count_a < count_b:
return a
else:
return b