Cody

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

Solution 661610

Submitted on 27 Apr 2015 by Li Yjie
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))

b = 1 0 0 1 1 0 0 n = 7 m = 3 c = 1 1 1 d = 0 0 0 0 e = 1 1 1 0 0 0 0 e = 1 1 1 0 0 0 0 e = 1110000 e = 112

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

b = 1 0 0 0 1 0 1 0 1 1 n = 10 m = 5 c = 1 1 1 1 1 d = 0 0 0 0 0 e = 1 1 1 1 1 0 0 0 0 0 e = 1 1 1 1 1 0 0 0 0 0 e = 1111100000 e = 992

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

b = 1 1 1 1 1 0 1 0 0 0 n = 10 m = 6 c = 1 1 1 1 1 1 d = 0 0 0 0 e = 1 1 1 1 1 1 0 0 0 0 e = 1 1 1 1 1 1 0 0 0 0 e = 1111110000 e = 1008

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

b = 1 0 0 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0 n = 24 m = 8 c = 1 1 1 1 1 1 1 1 d = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 e = 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 e = 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 e = 111111110000000000000000 e = 16711680