This notebook was prepared by [Donne Martin](http://donnemartin.com). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges).

Challenge Notebook

Constraints

See the HackerRank problem page.

Test Cases

See the HackerRank problem page.

Algorithm

Refer to the Solution Notebook. If you are stuck and need a hint, the solution notebook's algorithm discussion might be a good place to start.

Code


In [ ]:
def max_xor(lower, upper):
    # TODO: Implement me
    pass

Unit Test

The following unit test is expected to fail until you solve the challenge.


In [ ]:
# %load test_maximizing_xor.py
from nose.tools import assert_equal


class TestMaximingXor(object):

    def test_maximizing_xor(self):
        assert_equal(max_xor(10, 15), 7)
        print('Success: test_maximizing_xor')


def main():
    test = TestMaximingXor()
    test.test_maximizing_xor()


if __name__ == '__main__':
    main()

Solution Notebook

Review the Solution Notebook for a discussion on algorithms and code solutions.