Skip to content

adding a max_sectors_of_circle algorithm #8778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
21 changes: 21 additions & 0 deletions maths/max_sectors_of_circle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def max_sectors_of_circle(num_cuts: float) -> float:
"""
returns the maximum amount of
sectors a circle can be divided
by if cut 'num_cuts' times

>>> max_sectors_of_circle(54)
1486.0
>>> max_sectors_of_circle(7)
29.0
>>> max_sectors_of_circle(22.5)
265.375
>>> max_sectors_of_circle(-222)
-1
"""

return ((num_cuts + 2 + num_cuts**2) * (1 / 2)) if num_cuts >= 0 else -1


if __name__ == "__main__":
__import__("doctest").testmod()