Cody

Problem 2270. Bit calculation

Solution 2647583

Submitted on 3 Jul 2020 by Bence Cseppento
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
n = 1; y_correct = 0; assert(isequal(ret_count(n),y_correct))

2   Pass
n = 4; y_correct = 1; assert(isequal(ret_count(n),y_correct))

ans = 4×3 char array '001' '010' '011' '100' ans = 1

3   Pass
n = 72; y_correct = 18; assert(isequal(ret_count(n),y_correct))

ans = 72×7 char array '0000001' '0000010' '0000011' '0000100' '0000101' '0000110' '0000111' '0001000' '0001001' '0001010' '0001011' '0001100' '0001101' '0001110' '0001111' '0010000' '0010001' '0010010' '0010011' '0010100' '0010101' '0010110' '0010111' '0011000' '0011001' '0011010' '0011011' '0011100' '0011101' '0011110' '0011111' '0100000' '0100001' '0100010' '0100011' '0100100' '0100101' '0100110' '0100111' '0101000' '0101001' '0101010' '0101011' '0101100' '0101101' '0101110' '0101111' '0110000' '0110001' '0110010' '0110011' '0110100' '0110101' '0110110' '0110111' '0111000' '0111001' '0111010' '0111011' '0111100' '0111101' '0111110' '0111111' '1000000' '1000001' '1000010' '1000011' '1000100' '1000101' '1000110' '1000111' '1001000' ans = 18