Consider an \$n \times n\$ grid and a circle of radius \$r \leq \sqrt{2} n\$ with its center in the top left. In each square there is an integer from the range -3 to 3, inclusive. For a given radius, there is a set of squares in the grid which are not at least half covered by a circle of radius \$r\$ but are at least half covered by a circle of larger radius. Your task to output the sum of the integers in those squares.
Takes this example:
The smaller circle has radius \$3.5 \cdot \sqrt{2}\$ and the larger circle has radius \$4.5 \cdot \sqrt{2}\$. The numbers for squares that are at least half covered by the larger circle but not the smaller one are \$1, -1, 3, 3, 2, -1, -1, 1, -3, -1, 1\$. These sum to \$4\$.
You might be wondering why the \$-1\$ number in square (4,4) is not included. If we zoom in we can see why. The blue dots are the center of the squares.
If we had chosen the smaller radius to be \$2.5 \cdot \sqrt{2}\$ and the larger circle has radius \$3.5 \cdot \sqrt{2}\$ then we get the sum of the values we need is \$-1\$.
Here is the matrix from the examples given:
[[ 3, 0, 1, 3, -1, 1, 1, 3, -2, -1],
[ 3, -1, -1, 1, 0, -1, 2, 1, -2, 0],
[ 2, 2, -2, 0, 1, -3, 0, -2, 2, 1],
[ 0, -3, -3, -1, -1, 3, -2, 0, 0, 3],
[ 2, 2, 3, 2, -1, 0, 3, 0, -3, -1],
[ 1, -1, 3, 1, -3, 3, -2, 0, -3, 0],
[ 2, -2, -2, -3, -2, 1, -2, 0, 0, 3],
[ 0, 3, 0, 1, 3, -1, 2, -3, 0, -2],
[ 0, -2, 2, 2, 2, -2, 0, 2, 1, 3],
[-2, -2, 0, -2, -2, 2, 0, 2, 3, 3]]
Input
A 10 by 10 matrix of integers in the range -3 to 3, inclusive and a radius \$r=\sqrt{2} (a+1/2)\$ where \$a\$ is a non negative integer. The radius input will be the integer \$a\$.
Output
The sum of the numbers in the squares in the matrix which are not at least half covered by a circle of radius \$r\$ but are at least half covered by a circle of radius \$r + \sqrt{2}\$.
These are the outputs for some different values of \$a\$ using the example matrix.
a = 0 gives output 6 ( 0 + 3 + 3)
a = 1 gives output 3 (1 + -1 + -1 + 2 + 2)
a = 2 gives output -1 (3 + -1 + 1 + 0 + -2 + -3 + -3 + +0 + 2 + 2)
a = 3 gives output 4 (1 + -1 + -3 + 1 + -1 + -1 + 2 + 3 + 3 + -1 + 1)
Accuracy
Your answer should be exactly correct. The question of which squares to include can be resolved exactly mathematically.