Nickarin's blog

By Nickarin, history, 13 months ago, In English

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: matrix1 = [ [4, 4, 4, 4, 4], [4, 2, 3, 3, 3], [4, 2, 1, 1, 3], [4, 2, 2, 1, 3], [4, 4, 4, 4, 3] ]

Btw in the center you can start with 0 too

Example 2: matrix2 = [ [2, 2, 2], [2, 1, 1], [2, 2, 1] ]

I did a code but it definitely doesnt work

  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?