Skip to content

Instantly share code, notes, and snippets.

@Xjs
Created November 17, 2011 18:34
Show Gist options
  • Save Xjs/1374021 to your computer and use it in GitHub Desktop.
Save Xjs/1374021 to your computer and use it in GitHub Desktop.
argh11
a = int(input("a: "))
b = int(input("b: "))
P = 0
C = 0
D = 1
while (a > 0) or (b > 0) or (C > 0):
X = a % 2
Y = b % 2
if (X != Y) != C:
P = P+D
C = (X and Y) or (Y and C) or (X and C)
D = 2 * D
a = a // 2
b = b // 2
print("P: {number}".format(number=P))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment