You are viewing a single comment's thread. Return to all comments →
using maths
def theGreatXor(x): x=(bin(x)[2:]) i=0 while i<len(x) and x[i]=='1': i+=1 n=len(x) tot=2**(n-i) while i<len(x): while i<len(x) and x[i]=='0': i+=1 if i<n: tot-=(2**(n-i-1)) i+=1 return (tot-1)
Seems like cookies are disabled on this browser, please enable them to open this website
The Great XOR
You are viewing a single comment's thread. Return to all comments →