Skip to content
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

Update minimum_coin_change.py #12580

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update minimum_coin_change.py
Add some input and output examples on top
  • Loading branch information
Cfengsu2002 authored Feb 16, 2025
commit 0bbf0ea76e478706b1fa9ea377465c52f5195c6f
38 changes: 38 additions & 0 deletions greedy_methods/minimum_coin_change.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
import sys
from doctest import testmod

Check failure on line 2 in greedy_methods/minimum_coin_change.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

greedy_methods/minimum_coin_change.py:1:1: I001 Import block is un-sorted or un-formatted
"""
Test cases:
Do you want to enter your denominations ? (Y/N) :N
Enter the change you want to make in Indian Currency: 987
Following is minimal change for 987 :
500 100 100 100 100 50 20 10 5 2

Do you want to enter your denominations ? (Y/N) :Y
Enter number of denomination:10
1
5
10
20
50
100
200
500
1000
2000
Enter the change you want to make: 18745
Following is minimal change for 18745 :
2000 2000 2000 2000 2000 2000 2000 2000 2000 500 200 20 20 5

Do you want to enter your denominations ? (Y/N) :N
Enter the change you want to make: 0
The total value cannot be zero or negative.
Do you want to enter your denominations ? (Y/N) :N
Enter the change you want to make: -98
The total value cannot be zero or negative.
Do you want to enter your denominations ? (Y/N) :Y
Enter number of denomination:5
1
5
100
500
1000
Enter the change you want to make: 456
Following is minimal change for 456 :
100 100 100 100 5 5 5 5 5 5 5 5 5 5 5 1
"""
def find_minimum_change(denominations: list[int], value: int) -> list[int]:
"""
Find the minimum change from the given denominations and value.
Expand Down
Loading