Created
February 11, 2014 15:12
-
-
Save wiennat/8936671 to your computer and use it in GitHub Desktop.
if (A xor B) xor (A xor C) === (B xor C)?
This file contains hidden or 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
| A = '00001111' | |
| B = '00110011' | |
| C = '01010101' | |
| def to_bool(s): | |
| return map(lambda c: True if c == '1' else False, s) | |
| def xorTuple(el): | |
| return el[0] != el[1] | |
| def main(): | |
| bA = to_bool(A) | |
| bB = to_bool(B) | |
| bC = to_bool(C) | |
| bAB = zip(bA, bB) | |
| bAC = zip(bA, bC) | |
| bBC = zip(bB, bC) | |
| AxB = map(xorTuple, bAB) | |
| AxC = map(xorTuple, bAC) | |
| BxC = map(xorTuple, bBC) | |
| bABAC = zip(AxB, AxC) | |
| AxBxAxC = map(xorTuple, bABAC) | |
| print all(map(lambda x: x[0] == x[1], zip(BxC, AxBxAxC))) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment