Last active
April 21, 2017 14:32
-
-
Save hrubantjakub1/ad066e3e6007b6c719eb9f7cd0ad3803 to your computer and use it in GitHub Desktop.
my solution for codility task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// find odd element in array | |
def solution(A): | |
accessed = [False] * len(A) | |
randit = len(A) | |
for a in range(len(A)): | |
if accessed[a] == False: | |
for b in range(len(A)): | |
if a == b: | |
continue | |
if accessed[b] == False: | |
if A[a] == A[b]: | |
accessed[a] = True | |
accessed[b] = True | |
if(accessed[a] == False): | |
return A[a] | |
B = [6,2,9,2,3,6,7,3,1,7,9,1,5] | |
print(solution(B)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment