Cody

# Problem 793. Combinations without using nchoosek

Solution 1693348

Submitted on 16 Dec 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 = 3; y_correct = nchoosek(1:n,2); assert(isequal(your_fcn_name(n),y_correct)) % Prevents cheating filetext = fileread('your_fcn_name.m') assert(isempty(strfind(filetext, 'nchoosek')))

a = 1 2 1 3 1 4 2 3 2 4 3 4

Output argument "ans" (and maybe others) not assigned during call to "your_fcn_name". Error in Test1 (line 3) assert(isequal(your_fcn_name(n),y_correct))

2   Fail
n = 25; y_correct = nchoosek(1:n,2); assert(isequal(your_fcn_name(n),y_correct)) filetext = fileread('your_fcn_name.m') assert(isempty(strfind(filetext, 'nchoosek')))

a = 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 4 5 4 6 4 7 4 8 4 9 4 10 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 5 6 5 7 5 8 5 9 5 10 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 6 7 6 8 6 9 6 10 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 6 28 6 29 6 30 6 31 6 32 6 33 7 8 7 9 7 10 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 7 26 7 27 7 28 7 29 7 30 7 31 7 32 7 33 8 9 8 10 8 18 8 19 8 20 8 21 8 22 8 23 8 24 8 25 8 26 8 27 8 28 8 29 8 30 8 31 8 32 8 33 9 10 9 18 9 19 9 20 9 21 9 22 9 23 9 24 9 25 9 26 9 27 9 28 9 29 9 30 9 31 9 32 9 33 10 18 10 19 10 20 10 21 10 22 10 23 10 24 10 25 10 26 10 27 10 28 10 29 10 30 10 31 10 32 10 33 18 19 18 20 18 21 18 22 18 23 18 24 18 25 18 26 18 27 18 28 18 29 18 30 18 31 18 32 18 33 19 20 19 21 19 22 19 23 19 24 19 25 19 26 19 27 19 28 19 29 19 30 19 31 19 32 19 33 20 21 20 22 20 23 20 24 20 25 20 26 20 27 20 28 20 29 20 30 20 31 20 32 20 33 21 22 21 23 21 24 21 25 21 26 21 27 21 28 21 29 21 30 21 31 21 32 21 33 22 23 22 24 22 25 22 26 22 27 22 28 22 29 22 30 22 31 22 32 22 33 23 24 23 25 23 26 23 27 23 28 23 29 23 30 23 31 23 32 23 33 24 25 24 26 24 27 24 28 24 29 24 30 24 31 24 32 24 33 25 26 25 27 25 28 25 29 25 30 25 31 25 32 25 33 26 27 26 28 26 29 26 30 26 31 26 32 26 33 27 28 27 29 27 30 27 31 27 32 27 33 28 29 28 30 28 31 28 32 28 33 29 30 29 31 29 32 29 33 30 31 30 32 30 33 31 32 31 33 32 33

Output argument "ans" (and maybe others) not assigned during call to "your_fcn_name". Error in Test2 (line 3) assert(isequal(your_fcn_name(n),y_correct))

3   Fail
n = 112; y_correct = nchoosek(1:n,2); assert(isequal(your_fcn_name(n),y_correct)) filetext = fileread('your_fcn_name.m') assert(isempty(strfind(filetext, 'nchoosek')))

Error using dec2base (line 25) Second argument must be an integer, 2 <= B <= 36. Error in your_fcn_name (line 2) a=dec2base((0:(n+1)^2-1)',n+1,2)-'0'+1; Error in Test3 (line 3) assert(isequal(your_fcn_name(n),y_correct))

4   Fail
n = 2 y_correct = nchoosek(1:n,2); assert(isequal(your_fcn_name(n),y_correct)) filetext = fileread('your_fcn_name.m') assert(isempty(strfind(filetext, 'nchoosek')))

n = 2 a = 1 2 1 3 2 3

Output argument "ans" (and maybe others) not assigned during call to "your_fcn_name". Error in Test4 (line 3) assert(isequal(your_fcn_name(n),y_correct))