Same :D

Given that the task is very specific I'd say it is, as it is performant and the code is readable.

If you had to, for example, generate neighbors up to a variable distance n received as a parameter of the function, that would be a different story.

n

return the count

Do I have to return a table as the example shows?

The usual wording in math problems like this would be "non-negative". The description could either make an exception for 0, or just change "positive" to "non-negative" and give a clear example.

0

0 is neither positive or negative, so...

0 just can't be positive in standard math, so it has to be reworded somehow instead.

NASM Translation

Wonder if this is really a best practice, although it completely satisfies the task... Well done.

Same :D

Given that the task is very specific I'd say it is, as it is performant and the code is readable.

If you had to, for example, generate neighbors up to a variable distance

`n`

received as a parameter of the function, that would be a different story.return the count

Do I have to return a table as the example shows?

The usual wording in math problems like this would be "non-negative". The description could either make an exception for

`0`

, or just change "positive" to "non-negative" and give a clear example.0 is neither positive or negative, so...

`0`

just can't be positive in standard math, so it has to be reworded somehow instead.NASM Translation

Wonder if this is really a best practice, although it completely satisfies the task... Well done.