Browse Source

Solved Maximizing XOR

main
Titouan Rigoudy 11 years ago
parent
commit
e4fcc79687
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      max_xor/max_xor.py

+ 21
- 0
max_xor/max_xor.py View File

@ -0,0 +1,21 @@
#!/usr/bin/python3
# https://www.hackerrank.com/challenges/maximizing-xor
import sys
def max_xor(L,R):
res = 1
n = L ^ R
while n > 0:
n >>=1
res <<= 1
return res - 1
def main():
L = int(sys.stdin.readline())
R = int(sys.stdin.readline())
print(max_xor(L,R))
if __name__ == '__main__':
main()

Loading…
Cancel
Save