From aca385c30dd11d077bbf963becf4c385a382e92b Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Sat, 27 May 2023 15:19:08 +0300 Subject: [PATCH 1/7] adding a max_sectors_of_circle algorithm --- maths/max_sectors_of_circle.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 maths/max_sectors_of_circle.py diff --git a/maths/max_sectors_of_circle.py b/maths/max_sectors_of_circle.py new file mode 100644 index 000000000000..d7eb865994d0 --- /dev/null +++ b/maths/max_sectors_of_circle.py @@ -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() From 0d9f14f4be55cd48b2e8046ff27779d184640f7e Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Sat, 3 Jun 2023 15:01:31 +0300 Subject: [PATCH 2/7] following suggestions for maths/max_sectors_of_circle.py Co-authored-by: AmirSoroush <114881632+amirsoroush@users.noreply.github.com> --- maths/max_sectors_of_circle.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maths/max_sectors_of_circle.py b/maths/max_sectors_of_circle.py index d7eb865994d0..63c1107bb565 100644 --- a/maths/max_sectors_of_circle.py +++ b/maths/max_sectors_of_circle.py @@ -18,4 +18,6 @@ def max_sectors_of_circle(num_cuts: float) -> float: if __name__ == "__main__": - __import__("doctest").testmod() + import doctest + + doctest.testmod() From 72000463db2b5423f750e7a0c3a2318791dc2eb1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 3 Jun 2023 12:01:57 +0000 Subject: [PATCH 3/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/max_sectors_of_circle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/max_sectors_of_circle.py b/maths/max_sectors_of_circle.py index 63c1107bb565..7a6c47298d1b 100644 --- a/maths/max_sectors_of_circle.py +++ b/maths/max_sectors_of_circle.py @@ -19,5 +19,5 @@ def max_sectors_of_circle(num_cuts: float) -> float: if __name__ == "__main__": import doctest - + doctest.testmod() From f3661233d9b4b31f9676c632c30753d829f504c4 Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Wed, 21 Jun 2023 17:26:04 +0300 Subject: [PATCH 4/7] Updating max_sectors_of_circle.py following recommendations --- maths/max_sectors_of_circle.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/maths/max_sectors_of_circle.py b/maths/max_sectors_of_circle.py index 7a6c47298d1b..56056eeee614 100644 --- a/maths/max_sectors_of_circle.py +++ b/maths/max_sectors_of_circle.py @@ -12,8 +12,13 @@ def max_sectors_of_circle(num_cuts: float) -> float: 265.375 >>> max_sectors_of_circle(-222) -1 + >>> max_sectors_of_circle("-222") + Traceback (most recent call last): + TypeError: num_cuts must be a numeric value. """ + if not isinstance(num_cuts, (int, float)): + raise TypeError("num_cuts must be a numeric value.") return ((num_cuts + 2 + num_cuts**2) * (1 / 2)) if num_cuts >= 0 else -1 From 2db039c4745cb0a7dfc8fcbc04226072bb56c49c Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Thu, 22 Jun 2023 12:59:29 +0300 Subject: [PATCH 5/7] Implementing suggestions for maths/max_sectors_of_circle.py Co-authored-by: Christian Clauss --- maths/max_sectors_of_circle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/max_sectors_of_circle.py b/maths/max_sectors_of_circle.py index 56056eeee614..82d0d280a977 100644 --- a/maths/max_sectors_of_circle.py +++ b/maths/max_sectors_of_circle.py @@ -19,7 +19,7 @@ def max_sectors_of_circle(num_cuts: float) -> float: if not isinstance(num_cuts, (int, float)): raise TypeError("num_cuts must be a numeric value.") - return ((num_cuts + 2 + num_cuts**2) * (1 / 2)) if num_cuts >= 0 else -1 + return ((num_cuts + 2 + num_cuts**2) * .5) if num_cuts >= 0 else -1 if __name__ == "__main__": From 3dfd3b6fcaf4e7ca2ad1dd395a1d9b81ddbb8ac1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 22 Jun 2023 10:00:37 +0000 Subject: [PATCH 6/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/max_sectors_of_circle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/max_sectors_of_circle.py b/maths/max_sectors_of_circle.py index 82d0d280a977..ac8855259519 100644 --- a/maths/max_sectors_of_circle.py +++ b/maths/max_sectors_of_circle.py @@ -19,7 +19,7 @@ def max_sectors_of_circle(num_cuts: float) -> float: if not isinstance(num_cuts, (int, float)): raise TypeError("num_cuts must be a numeric value.") - return ((num_cuts + 2 + num_cuts**2) * .5) if num_cuts >= 0 else -1 + return ((num_cuts + 2 + num_cuts**2) * 0.5) if num_cuts >= 0 else -1 if __name__ == "__main__": From 3cadfae84f27cf93f86acf9e17fa136d11df43eb Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sun, 25 Jun 2023 18:54:21 +0000 Subject: [PATCH 7/7] updating DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 0c21b9537fc1..80e69074ba76 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -605,6 +605,7 @@ * [Maclaurin Series](maths/maclaurin_series.py) * [Manhattan Distance](maths/manhattan_distance.py) * [Matrix Exponentiation](maths/matrix_exponentiation.py) + * [Max Sectors Of Circle](maths/max_sectors_of_circle.py) * [Max Sum Sliding Window](maths/max_sum_sliding_window.py) * [Median Of Two Arrays](maths/median_of_two_arrays.py) * [Miller Rabin](maths/miller_rabin.py)