You should write a program or function that given an N
by N
equally spaced square grid and a solid inscribed circle outputs or returns the number of grid squares which are overlapped partially or fully by the solid circle.
0-sized overlaps (i.e. when the circle only touches a line) are not counted. (These overlaps occur at e.g. N = 10
.)
Example
N = 8 (64 squares), Slices = 60
Input
- An integer
N > 0
. (The grid wil haveN * N
squares.)
Output
- An integer, the number of solid circle slices.
Examples
(input-output pairs)
Inputs: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Outputs: 1 4 9 16 25 36 45 60 77 88 109 132 149 172 201
This is code-golf so shortest entry wins.
N^2
. \$\endgroup\$