Spiral Matrix
Difference between en1 and en2, changed 114 character(s)
**Can someone help me find a different and right solution?**↵
I tried to do it but it gives me the wrong answer, i found a pattern and i want  to share it even if its wrong↵

Here comes the instructions and my interpretation...↵
- Start from the center of the matrix.↵
- Move in a spiral: right → down → left → up → repeat.↵
**The steps of the numbers**↵
You move 1 step in the first direction, then 1 step in the second,↵
Then 2 steps in the next direction, 2 steps in the following,↵
Then 3 steps, 3 steps, and so on.↵
This is the rule you were seeing: each number “occupies” two turns before increasing.↵

Hope someone gets to see this (sorry if its confusing english is not my native language)↵

Here are some examples ↵

Example 1:↵
4matrix1 = [↵
    [4,
 4, 4, 4, 4
4
],↵
    [4,
 2, 3, 3, 3
4
],↵
    [4,
 2, 1, 1, 3
4
],↵
    [4,
 2, 2, 1, 3
4
],↵
    [4,
 4, 4, 4, 3]↵
]↵

Btw in the center you can start with 0 too↵

Example 2:↵

2
matrix2 = [↵
    [2,
 2, 2
2
],↵
    [2,
 1, 1
2
],↵
    [2,
 2, 1]↵
]↵



I did a code but it definitely doesnt work↵

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Nickarin 2025-10-09 03:27:35 114
en1 English Nickarin 2025-10-09 03:25:22 939 Initial revision (published)