Skip to content

Commit

Permalink
Challenge_2 in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
ajschrier committed Jan 3, 2017
1 parent 451b84a commit 55e5b57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions challenge_2/python/ajschrier/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Challenge 2 - Single Number

Created a solution that checks a candidate list and a known incompatible list, but I don't think that it meets the time requirement.
18 changes: 18 additions & 0 deletions challenge_2/python/ajschrier/challenge_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
array1 = [2, 3, 4, 2, 3, 5, 4, 6, 4, 6, 9, 10, 9, 8, 7, 8, 10, 7]
array2 = [2, 'a', 'l', 3, 'l', 4, 'k', 2, 3, 4, 5, 'a', 6, 'c', 4, 'm', 6, 'm', 'k', 9, 10, 9, 8, 7, 8, 10, 7] # noqa


def singletonCharacters(array):
candidateCharacters = []
failedCharacters = []
for i in array:
if i not in failedCharacters:
if i in candidateCharacters:
candidateCharacters.remove(i)
failedCharacters.append(i)
else:
candidateCharacters.append(i)
return candidateCharacters

print singletonCharacters(array1)
print singletonCharacters(array2)

0 comments on commit 55e5b57

Please sign in to comment.