Cody

# Problem 2738. Sideways sum

Solution 1588478

Submitted on 20 Jul 2018
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   Fail
N = 1; num_ones = 1; assert(isequal(popcount(N),num_ones))

Undefined function or variable 'N'. Error in popcount (line 2) population =log(N+1)/log(2) Error in Test1 (line 3) assert(isequal(popcount(N),num_ones))

2   Fail
N = 2; num_ones = 1; assert(isequal(popcount(N),num_ones))

Undefined function or variable 'N'. Error in popcount (line 2) population =log(N+1)/log(2) Error in Test2 (line 3) assert(isequal(popcount(N),num_ones))

3   Fail
N = 3; num_ones = 2; assert(isequal(popcount(N),num_ones))

Undefined function or variable 'N'. Error in popcount (line 2) population =log(N+1)/log(2) Error in Test3 (line 3) assert(isequal(popcount(N),num_ones))

4   Fail
for num_ones = 3:10 N = 2^num_ones-1; assert(isequal(popcount(N),num_ones)) end

Undefined function or variable 'N'. Error in popcount (line 2) population =log(N+1)/log(2) Error in Test4 (line 3) assert(isequal(popcount(N),num_ones))

5   Fail
for num_ones = 1:50 N = sum(2.^(find(randperm(50)<=num_ones)-1)); assert(isequal(popcount(N),num_ones)) end

Undefined function or variable 'N'. Error in popcount (line 2) population =log(N+1)/log(2) Error in Test5 (line 3) assert(isequal(popcount(N),num_ones))

6   Fail
N = 23; num_ones = 4; assert(isequal(popcount(N),num_ones))

Undefined function or variable 'N'. Error in popcount (line 2) population =log(N+1)/log(2) Error in Test6 (line 3) assert(isequal(popcount(N),num_ones))

7   Fail
N = 123; num_ones = 6; assert(isequal(popcount(N),num_ones))

Undefined function or variable 'N'. Error in popcount (line 2) population =log(N+1)/log(2) Error in Test7 (line 3) assert(isequal(popcount(N),num_ones))

8   Fail
N = 123456; num_ones = 6; assert(isequal(popcount(N),num_ones))

Undefined function or variable 'N'. Error in popcount (line 2) population =log(N+1)/log(2) Error in Test8 (line 3) assert(isequal(popcount(N),num_ones))

9   Fail
N = 1234567; num_ones = 11; assert(isequal(popcount(N),num_ones))

Undefined function or variable 'N'. Error in popcount (line 2) population =log(N+1)/log(2) Error in Test9 (line 3) assert(isequal(popcount(N),num_ones))

10   Fail
N = 1125899906842501; num_ones = 45; assert(isequal(popcount(N),num_ones))

Undefined function or variable 'N'. Error in popcount (line 2) population =log(N+1)/log(2) Error in Test10 (line 3) assert(isequal(popcount(N),num_ones))