Cody

# Problem 1488. Generate binary combinations for a given number of bit(s)

Solution 3070435

Submitted on 5 Oct 2020 by Nikolaos Nikolaou
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
bits = 1; y_correct = [0; 1]; assert(isequal(bin_comb(bits),y_correct))

b = 0 b = 0 1

2   Pass
bits = 2; y_correct = [0 0;0 1; 1 0; 1 1] assert(isequal(bin_comb(bits),y_correct))

y_correct = 0 0 0 1 1 0 1 1 b = 0 0 b = 0 0 0 1 b = 0 0 0 1 1 0 b = 0 0 0 1 1 0 1 1

3   Pass
bits = 3; y_correct = [0 0 0;0 0 1;0 1 0;0 1 1;1 0 0; 1 0 1; 1 1 0; 1 1 1] assert(isequal(bin_comb(bits),y_correct))

y_correct = 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 b = 0 0 0 b = 0 0 0 0 0 1 b = 0 0 0 0 0 1 0 1 0 b = 0 0 0 0 0 1 0 1 0 0 1 1 b = 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 b = 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 b = 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 b = 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1

### Community Treasure Hunt

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

Start Hunting!