11
0
I started a CodeWars kata in Python, just two days ago, related to code golf.
Task: Given two congruent circles a and b of radius r, return the area of their intersection rounded down to the nearest integer, in less than 128 chars.
Has to be a one-liner.
Version: Python 3.6
External libraries: You may import NumPy as an external library.
Function name:
circleIntersection
Input example:
circleIntersection([0,0],[0,10], 10)
This is the closest I could come (129):
from math import*;circleIntersection=lambda a,b,r:r*r*(lambda h:h<1and acos(h)-h*(1-h*h)**.5)(hypot(b[0]-a[0],b[1]-a[1])/r/2)//.5
You mention that 3.6 is the latest version provided -- is Python 2 an option? If so, I have a way to save bytes with that. It could also help to link the site's problem page if we can view that without login. – xnor – 2020-02-05T23:27:42.310
Yes, Python 2 is an option. You need to login in order to view the problem :( – Leo oeL – 2020-02-06T00:07:38.177