Your goal is to make a function that takes the coordinates of a cell in 2D space and a distance \$r\$ and returns the coordinates of all cells in the input coordinate's von Neumann neighborhood of radius \$r\$. That is, all cells at most \$r\$ away in Manhattan distance. For example, given the following cell coordinates and radius pairs:
[1, 1], 1 -> [0, 1], [1, 0], [1, 1], [1, 2], [2, 1]
[2, 2], 2 -> [0, 2], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [4, 2]
This is what the von Neumann neighborhood looks like:
More information about the von Neumann neighborhood can be found here.
This is code-golf, so shortest amount of bytes wins!
r
away", and a cell is 0 units away from itself, which is at mostr
) all point towards that. \$\endgroup\$