Update check_polygon.pyfix(maths): validate minimum sides for polygon in check_polygon.py by mohitkumar188 · Pull Request #15320 · TheAlgorithms/Python · GitHub
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

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 ....

@cclauss

cclauss commented Sep 15, 2026

Copy link
Copy Markdown
Member

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants