Skip to content

Update check_polygon.pyfix(maths): validate minimum sides for polygon in check_polygon.py - #15320

Open
mohitkumar188 wants to merge 2 commits into
TheAlgorithms:masterfrom
mohitkumar188:improve-maths-check-polygon
Open

Update check_polygon.pyfix(maths): validate minimum sides for polygon in check_polygon.py#15320
mohitkumar188 wants to merge 2 commits into
TheAlgorithms:masterfrom
mohitkumar188:improve-maths-check-polygon

Conversation

@mohitkumar188

Copy link
Copy Markdown

Describe your change:

  • Fixed condition len(nums) < 3 because polygons require at least 3 sides (triangles). Previously, 2-sided inputs did not raise the ValueError despite the error message stating digons are invalid.
  • Simplified sorting logic using sorted().
  • Added doctest for 2-element input ([4, 5]).

Checklist:

  • I have read the CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file.
  • All doctests pass with python -m doctest -v ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant