Problem 944. Create incremental spiral WITHOUT USING EVAL or FEVAL
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
Solution Stats
Problem Comments
-
4 Comments
Show
1 older comment
Jan Orwat
on 18 Sep 2014
Same problem.
rifat
on 19 Sep 2014
I also had the same problem
Dyuman Joshi
on 1 Sep 2021
The test suite has been updated to check for restricted functions with new test cases being added as well.
Solution Comments
Show commentsProblem Recent Solvers42
Suggested Problems
-
Return the 3n+1 sequence for n
8349 Solvers
-
Find common elements in matrix rows
2665 Solvers
-
3030 Solvers
-
Rotate input square matrix 90 degrees CCW without rot90
637 Solvers
-
Penny flipping - calculate winning probability (easy)
183 Solvers
More from this Author31
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!