Cody

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

Solution 1803025

Submitted on 2 May 2019 by Joanne Marsh
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))

i = 3 j = 7 y = 0 j = 6 y = 64 j = 5 y = 96 j = 4 y = 112

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

i = 5 j = 10 y = 0 j = 9 y = 512 j = 8 y = 768 j = 7 y = 896 j = 6 y = 960 j = 5 y = 992

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

i = 6 j = 10 y = 0 j = 9 y = 512 j = 8 y = 768 j = 7 y = 896 j = 6 y = 960 j = 5 y = 992 j = 4 y = 1008

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

i = 8 j = 24 y = 0 j = 23 y = 8388608 j = 22 y = 12582912 j = 21 y = 14680064 j = 20 y = 15728640 j = 19 y = 16252928 j = 18 y = 16515072 j = 17 y = 16646144 j = 16 y = 16711680