Cody

# Problem 108. Given an unsigned integer x, find the largest y by rearranging the bits in x

Solution 1992224

Submitted on 27 Oct 2019 by Tung Nguyen
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = 76; y_correct = 112; assert(isequal(maxit(x),y_correct))

n = 76 z = 1 z = 3 z = 7 z = 14 z = 28 z = 56 z = 112 y = 112

2   Pass
x = 555; y_correct = 992; assert(isequal(maxit(x),y_correct))

n = 555 z = 1 z = 3 z = 7 z = 15 z = 31 z = 62 z = 124 z = 248 z = 496 z = 992 y = 992

3   Pass
x = 1000; y_correct = 1008; assert(isequal(maxit(x),y_correct))

n = 1000 z = 1 z = 3 z = 7 z = 15 z = 31 z = 63 z = 126 z = 252 z = 504 z = 1008 y = 1008

4   Pass
x = 10000000; y_correct = 16711680; assert(isequal(maxit(x),y_correct))

n = 10000000 z = 1 z = 3 z = 7 z = 15 z = 31 z = 63 z = 127 z = 255 z = 510 z = 1020 z = 2040 z = 4080 z = 8160 z = 16320 z = 32640 z = 65280 z = 130560 z = 261120 z = 522240 z = 1044480 z = 2088960 z = 4177920 z = 8355840 z = 16711680 y = 16711680

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!