Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Problem 944. Create incremental spiral WITHOUT USING EVAL or FEVAL

Created by J-G van der Toorn

Constructions that use feval or eval are used to cheat with cody. This test-suite tries to avoid that trick.

The goal of this challenge is to create a numeric pyramid with size n*n, starting with 1 in the upper left corner, and cycling clockwise until the center, by every step incrementing with one. It is not allowed to use eval or feval statements to get a lower node-count. Neither are regexp, regexprep, regexpi, eval, evalc, evalin, nor inline allowed.

For example:

n = 3;
ans =
     1     2     3
     8     9     4
     7     6     5
n = 6;
ans =
     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

Tags

Problem Group

Solution Statistics

49 correct solutions 21 incorrect solutions
Last solution submitted on Jun 24, 2016

Problem Comments

Solution Comments