Cody

Solution 159461

Submitted on 8 Nov 2012 by GABRIEL
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
%% 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)))

y = 3 2 1 1 1 1 1 1 1 y = 5 4 3 1 1 2 1 1 1 y = 7 6 5 1 1 4 1 2 3 y = 9 8 7 2 1 6 3 4 5 y = 1 y = 1 y = 1 y = 1 y = 6 5 4 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 y = 11 10 9 8 7 6 1 1 1 1 1 5 1 1 1 1 1 4 1 1 1 1 1 3 1 1 1 1 1 2 1 1 1 1 1 1 y = 16 15 14 13 12 11 1 1 1 1 1 10 1 1 1 1 1 9 1 1 1 1 1 8 1 1 1 1 1 7 1 2 3 4 5 6 y = 21 20 19 18 17 16 2 1 1 1 1 15 3 1 1 1 1 14 4 1 1 1 1 13 5 1 1 1 1 12 6 7 8 9 10 11 y = 4 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1 y = 7 6 5 4 1 1 1 3 1 1 1 2 1 1 1 1 y = 10 9 8 7 1 1 1 6 1 1 1 5 1 2 3 4 y = 13 12 11 10 2 1 1 9 3 1 1 8 4 5 6 7 y = 2 1 1 1 y = 3 2 1 1 y = 4 3 1 2 y = 5 4 2 3 y = 1 y = 1 y = 1 y = 1