Skip to content

Instantly share code, notes, and snippets.

@akshaykarthik
Created March 2, 2016 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akshaykarthik/b97d663588b9a3b110a5 to your computer and use it in GitHub Desktop.
Save akshaykarthik/b97d663588b9a3b110a5 to your computer and use it in GitHub Desktop.
Computer Science Group Question 2
import math
# assume data is tuples of the form ((x, y), r)
def find_area(large, smalls):
def distance(first, second):
a, b = first[0]
c, d = second[0]
return math.hypot(c-a, d-b)
def area(circle):
return circle[1]**2 * math.PI
final_area = area(large)
for small in smalls:
if distance(large, small) <= large[2] - small[1]:
final_area -= area(small)
return final_area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment