Intersection of circles – How can I reduce this golf code to 127 bytes? 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&lt;1and acos(h)-h*(1-h*h)**.5)(hypot(b[0]-a[0],b[1]-a[1])/r/2)//.5
Use Python 2's arg unpacking: 124 bytes



from math import*;circleIntersection=lambda(v,w),(x,y),r:r*r*(lambda h:h&lt;1and acos(h)-h*(1-h*h)**.5)(hypot(v-x,w-y)/r/2)//.5


Try it online!

Python 2 has parameter unpacking, allowing the input point arguments to be taken directly as pairs (v,w) and (x,y), where the input lists like [0,0] and [0,10] will be unpacked into the respective variables. This feature was removed in Python 3 -- a pity, in my opinion, since the old syntax seems more readable. But, the site has a Python 2 option, and nothing in your solution relies on Python 3.