This website works better with JavaScript.
Home
Explore
Help
Sign In
titouan
/
hackerrank
Watch
1
Star
0
Fork
0
Code
Issues
0
Pull Requests
0
Releases
0
Wiki
Activity
Browse Source
Solved Maximizing XOR
main
Titouan Rigoudy
11 years ago
parent
afe5732c5a
commit
e4fcc79687
1 changed files
with
21 additions
and
0 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+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
(
)
Write
Preview
Loading…
Cancel
Save