Cody

# Problem 944. Create incremental spiral WITHOUT USING EVAL or FEVAL

Solution 187056

Submitted on 6 Jan 2013 by Mehmet OZC
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 = 1 2 3 8 9 4 7 6 5 y = 11 12 13 14 15 16 10 27 28 29 30 17 9 26 35 36 31 18 8 25 34 33 32 19 7 24 23 22 21 20 6 5 4 3 2 1 y = 1