Forked from aavrug/gist:f8212bc4a22a55486879d8e51e8fdf7f
Last active
July 15, 2017 13:22
-
-
Save blubberdiblub/b9510567b1e7f0988ee2f1cbf60e5019 to your computer and use it in GitHub Desktop.
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
//Previous code | |
a = list(map(int, raw_input().split())) | |
for i in a: | |
if a.count(i) == 1: | |
print i | |
break | |
// Current code | |
from collections import Counter | |
a = list(map(int, raw_input().split())) | |
b = Counter(a) | |
onlies = [k for k,v in b if v == 1] | |
print onlies | |
# one way using sets | |
present = set() | |
morelies = set() | |
for i in a: | |
if i in present: | |
morelies.add(i) | |
else: | |
present.add(i) | |
onlies = present - morelies | |
print(onlies) | |
# another way using sets | |
onlies = set() | |
morelies = set() | |
for i in a: | |
if i in morelies: | |
pass | |
elif i in onlies: | |
morelies.add(i) | |
onlies.remove(i) | |
else: | |
onlies.add(i) | |
print(onlies) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment