Cody

Problem 1895. Count ones

Solution 2583478

Submitted on 19 Jun 2020 by Ramesh Kumar V
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 = 1123421; y_correct = 3; assert(isequal(your_fcn_name(x),y_correct))

m = 1 sum = 1 a = 112342 m = 1 2 a = 11234 m = 1 2 4 a = 1123 m = 1 2 4 3 a = 112 m = 1 2 4 3 2 a = 11 m = 1 2 4 3 2 1 sum = 2 a = 1 m = 1 2 4 3 2 1 1 sum = 3 a = 0 b = 3

2   Pass
x = 1111; y_correct = 4; assert(isequal(your_fcn_name(x),y_correct))

m = 1 sum = 1 a = 111 m = 1 1 sum = 2 a = 11 m = 1 1 1 sum = 3 a = 1 m = 1 1 1 1 sum = 4 a = 0 b = 4

3   Pass
x = 345450; y_correct = 0; assert(isequal(your_fcn_name(x),y_correct))

m = 0 a = 34545 m = 0 5 a = 3454 m = 0 5 4 a = 345 m = 0 5 4 5 a = 34 m = 0 5 4 5 4 a = 3 m = 0 5 4 5 4 3 a = 0 b = 0

Suggested Problems

Community Treasure Hunt

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

Start Hunting!