Skip to content
New issue

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

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

Already on GitHub? # to your account

Update minimum_coin_change.py #12580

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

Cfengsu2002
Copy link

Fix: Improve minimum coin change logic & add doctest

  • Removed unnecessary int() conversions to improve efficiency.
  • Updated function parameter type (value: str → value: int) to avoid redundant type casting.
  • Added try-except handling to prevent ValueError when user input is not a number.
  • Implemented testmod() to enable automated doctest verification.
  • Fixed issue where input denominations were not sorted in descending order, which previously led to incorrect results.

Cfengsu2002 and others added 2 commits February 16, 2025 03:57
Fix: Improve minimum coin change logic & add doctest

- Removed unnecessary int() conversions to improve efficiency.
- Updated function parameter type (value: str → value: int) to avoid redundant type casting.
- Added try-except handling to prevent ValueError when user input is not a number.
- Implemented testmod() to enable automated doctest verification.
- Fixed issue where input denominations were not sorted in descending order, which previously led to incorrect results.
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Feb 16, 2025
@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Feb 16, 2025
Finished and formatted
@algorithms-keeper algorithms-keeper bot added tests are failing Do not merge until tests pass labels Feb 16, 2025
@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Feb 16, 2025
Add some input and output examples on top
@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Feb 16, 2025
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Feb 16, 2025
Cfengsu2002 and others added 2 commits February 16, 2025 05:00
The correct version with input and output explanation
@algorithms-keeper algorithms-keeper bot added tests are failing Do not merge until tests pass and removed tests are failing Do not merge until tests pass labels Feb 16, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
awaiting reviews This PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants