Last active
March 31, 2016 11:51
-
-
Save neugen86/b095994d9d64b073dde6da461c0a6325 to your computer and use it in GitHub Desktop.
Example_1
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
import random | |
a = 77 | |
b = 88 | |
print "a = ", a | |
print "b = ", b | |
array = [] | |
for i in range(1, 5): | |
for j in range(2): | |
array.append(512 * i) | |
array.append(a) | |
array.append(b) | |
random.shuffle(array) | |
print "array = ", array | |
a = 0 | |
b = 0 | |
xor = 0 | |
for i in array: | |
xor = xor ^ i | |
# First non-zero bit | |
bit = xor & ~(xor - 1) | |
for i in array: | |
if i & bit: | |
a = a ^ i | |
else: | |
b = b ^ i | |
print "xor = ", bin(xor) | |
print "a = ", a, " (", bin(a), ")" | |
print "b = ", b, " (", bin(b), ")" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment