Description :
Given x
and y
positions of two circles along with their radii
, output the area of intersection of the two circle.
Input :
You will be given following input :
array 1 = x and y positions of circle a
array 2 = x and y positions of circle b
radius = radii of the two congruent circles
Input method :
([12 , 20] , [20 , 18] , 12) ---> two array and number
([12 , 20 , 20 , 18] , 12) ---> array and a number
(12 , 20 , 20 , 18 , 12) ---> all five numbers
('12 20' , '20 18' , 12) ---> 2 strings and a number
('12 20 20 18' , 12) ---> string and a number
('12 20 20 18 12') ---> one string
Output :
A non-negative integer (no decimal) equal to area of intersection of two circles.
A string equal to the above mentioned integer.
Note :
- Output must be >= 0, since area can't be negative.
- In case of decimal round down to nearest integer
Examples :
([0, 0], [7, 0], 5) ---> 14
([0, 0], [0, 10], 10) ---> 122
([5, 6], [5, 6], 3) ---> 28
([-5, 0], [5, 0], 3) ---> 0
([10, 20], [-5, -15], 20) ---> 15
([-7, 13], [-25, -5], 17) ---> 132
([-12, 20], [43, -49], 23) ---> 0
Winning criteria :
This is code-golf so shortest code in bytes for each language wins.
Suggestions :
- Provide a TIO link so it can be tested.
- Provide an explanation so others can understand your code
These are only suggestions and are not mandatory.
answer must be positive
toanswer must be >= 0
- If the circles don't intersect (as in examples 4, 7, 10) then the correct answer is 0, which last I checked is not positive. \$\endgroup\$