This solution is outdated. To rescore this solution, sign in.
-
1 Comment
GeeTwo
on 4 Jul 2022
As I commented elsewhere, only 1198 loops are necessary. The longest path in a square array avoiding adjacent squares is a spiral from a corner to a point near the center. (For odd, a deep slalom gives the same answer.) The number of steps is:
odd: (n^2+2n-3)/2
even:(n^2+2n-4)/2
For 48, this is 1198, not 2500.
Suggested Problems
-
Find the two most distant points
2882 Solvers
-
Read a column of numbers and interpolate missing data
2317 Solvers
-
Getting the row and column location from a matrix
288 Solvers
-
678 Solvers
-
5300 Solvers
More from this Author3
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!