Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 105968

Submitted on 3 Jul 2012 by Tim

Correct

60Size
Leading solution size is 30.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
n = 2;
m = 1;
a = twist_n_match(n,m);
[r,c] = size(a);
assert(r==n && c==n);
assert(isequal(nnz(a==rot90(a)),m));

                    
2
Pass
 
%%
n = 3;
m = 7;
a = twist_n_match(n,m);
[r,c] = size(a);
assert(r==n && c==n);
assert(isequal(nnz(a==rot90(a)),m));

                    
3
Pass
 
%%
n = 6;
m = 6;
a = twist_n_match(n,m);
[r,c] = size(a);
assert(r==n && c==n);
assert(isequal(nnz(a==rot90(a)),m));

                    
4
Pass
 
%%
n = 10;
m = 11;
a = twist_n_match(n,m);
[r,c] = size(a);
assert(r==n && c==n);
assert(isequal(nnz(a==rot90(a)),m));

                    
5
Pass
 
%%
n = 10;
m = 14;
a = twist_n_match(n,m);
[r,c] = size(a);
assert(r==n && c==n);
assert(isequal(nnz(a==rot90(a)),m));

                    
6
Pass
 
%%
n = 20;
m = 83;
a = twist_n_match(n,m);
[r,c] = size(a);
assert(r==n && c==n);
assert(isequal(nnz(a==rot90(a)),m));

                    
7
Pass
 
%%
n = 21;
m = 1;
a = twist_n_match(n,m);
[r,c] = size(a);
assert(r==n && c==n);
assert(isequal(nnz(a==rot90(a)),m));