Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
fid = fopen('feval.m','w');
fprintf(fid,'function feval(a)\nerror;\n');
fclose(fid);
fid = fopen('eval.m','w');
fprintf(fid,'function eval(a)\nerror;\n');
fclose(fid);
forbidden = '(eval|regexp|inline)';
x = 3;
y_correct = [
1 2 3
8 9 4
7 6 5
];
assert(isequal(pyramid(x),y_correct) && isempty(regexp(evalc('type pyramid'),forbidden)))
x = 6;
y_correct = [
1 2 3 4 5 6
20 21 22 23 24 7
19 32 33 34 25 8
18 31 36 35 26 9
17 30 29 28 27 10
16 15 14 13 12 11
];
assert(isequal(pyramid(x),y_correct) && isempty(regexp(evalc('type pyramid'),forbidden)))
x = 1;
y_correct = 1;
assert(isequal(pyramid(x),y_correct) && isempty(regexp(evalc('type pyramid'),forbidden)))
|
12380 Solvers
Return the 3n+1 sequence for n
6167 Solvers
Duplicate each element of a vector.
518 Solvers
Change the sign of even index entries of the reversed vector
296 Solvers
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
297 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!