Cody

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

Solution 1938111

Submitted on 16 Sep 2019 by Nicolas
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 = 6 s0 = 0 s1 = 0 s1 = 1 x = 12 s0 = 1 s0 = 2 s1 = 2 x = 4 s1 = 3 x = 0 s0 = 3 s0 = 4 y = 112

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

n = 9 s0 = 0 s1 = 0 s1 = 1 x = 43 s0 = 1 s0 = 2 s0 = 3 s1 = 2 x = 11 s0 = 4 s1 = 3 x = 3 s0 = 5 s1 = 4 x = 1 s1 = 5 x = 0 y = 992

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

n = 9 s0 = 0 s1 = 0 s1 = 1 x = 488 s1 = 2 x = 232 s1 = 3 x = 104 s1 = 4 x = 40 s1 = 5 x = 8 s0 = 1 s1 = 6 x = 0 s0 = 2 s0 = 3 s0 = 4 y = 1008

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

n = 23 s0 = 0 s1 = 0 s1 = 1 x = 1611392 s0 = 1 s0 = 2 s1 = 2 x = 562816 s1 = 3 x = 38528 s0 = 3 s0 = 4 s0 = 5 s1 = 4 x = 5760 s0 = 6 s0 = 7 s1 = 5 x = 1664 s0 = 8 s1 = 6 x = 640 s1 = 7 x = 128 s0 = 9 s1 = 8 x = 0 s0 = 10 s0 = 11 s0 = 12 s0 = 13 s0 = 14 s0 = 15 s0 = 16 y = 16711680