diff --git a/ball_in_box/area_sum.py b/ball_in_box/area_sum.py index 67ad6df..4c548b8 100644 --- a/ball_in_box/area_sum.py +++ b/ball_in_box/area_sum.py @@ -1,27 +1,35 @@ import math + import ball_in_box.ballinbox as bb import ball_in_box.validate as val +import time + + def area_sum(circles): area = 0.0 for circle in circles: - area += circle[2]**2 * math.pi + area += circle[2] ** 2 * math.pi return area + if __name__ == '__main__': num_of_circle = 5 blockers = [(0.5, 0.5) - ,(0.5, -0.3)] - + , (0.5, -0.3)] + + begin = time.time() + circles = bb.ball_in_box(num_of_circle, blockers) - + + area = 0 + if num_of_circle == len(circles) and val.validate(circles, blockers): + area = area_sum(circles) print("Total area: {}".format(area)) else: print("Error: no good circles.") - - - + # print("Time:", time.time() - begin)