Created
March 29, 2016 16:53
-
-
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)
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 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