Skip to content

Instantly share code, notes, and snippets.

@xuefeng-huang
Created April 1, 2016 02:38
Show Gist options
  • Save xuefeng-huang/fe21f83e9addbd8ad89abf2c82660f44 to your computer and use it in GitHub Desktop.
Save xuefeng-huang/fe21f83e9addbd8ad89abf2c82660f44 to your computer and use it in GitHub Desktop.
find the outlier(odd from even or vice versa) from group of integers
def find_outlier(integers):
"""return the outlier from integer list"""
parity = [n % 2 for n in integers]
return integers[parity.index(1)] if sum(parity) == 1 else integers[parity.index(0)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment