Skip to content

Instantly share code, notes, and snippets.

@catb0t
Created March 29, 2016 16:53
Show Gist options
  • Save catb0t/bd8d9b305fdf53427039f08b1228e244 to your computer and use it in GitHub Desktop.
Save catb0t/bd8d9b305fdf53427039f08b1228e244 to your computer and use it in GitHub Desktop.
simple tool to find even numbers in a list of binary numbers (basic, simplistic solution that doesn't even look at the bits)
def find_even(binlist):
nums = list(map(lambda c: int(c, 2), binlist))
evens = list(map(lambda i: not i % 2, nums))
listof = list(zip(evens, nums, binlist))
return {i[1]:i[2] for i in list(filter(lambda g: g[0], listof))}
# >>> # copied directly from the google form
# >>> bins = """10101101
# 00000001
# 11100111
# 00000011
# 11111110""".split("\n")
# >>> find_even(bins)
# {254: '11111110'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment