Cody

Problem 2738. Sideways sum

Solution 2713734

Submitted on 20 Jul 2020
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))

Error in solution: Line: 2 Column: 46 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 46 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 46 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 46 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 46 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 46 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 46 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 46 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 46 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 46 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

Suggested Problems

More from this Author41

Community Treasure Hunt

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

Start Hunting!