Created
April 16, 2017 21:58
-
-
Save DeviaVir/cf9cd81356c6b5237af351eaa9217135 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
def main(): | |
values = map(int, raw_input().split(',')) | |
return reduce(lambda x, y: x ^ y, values) | |
print main() | |
# Because ^ (XOR) returns 0 for each pair and there is only one unpaired item in the input. | |
# E.g. | |
# 1 ^ 1 = 0 | |
# 2 ^ 2 = 0 | |
# 1 ^ 1 ^ 2 ^ 2 = 0 | |
# 1 ^ 1 ^ 2 = 2 | |
# 1 ^ 2 ^ 1 = 2 | |
# Pairs rule each other out. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment