Skip to content

Instantly share code, notes, and snippets.

@DeviaVir
Created April 16, 2017 21:58
Show Gist options
  • Save DeviaVir/cf9cd81356c6b5237af351eaa9217135 to your computer and use it in GitHub Desktop.
Save DeviaVir/cf9cd81356c6b5237af351eaa9217135 to your computer and use it in GitHub Desktop.
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