Skip to content

Commit a5ef4f3

Browse files
Added doctests.
doctests added to the function find_minimum_change.
1 parent 4bdc334 commit a5ef4f3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

greedy_method/greedy_coin_change.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,26 @@
3535
100
3636
500
3737
1000
38-
Enter the change you want to make in Indian Currency: 456
38+
Enter the change you want to make: 456
3939
Following is minimal change for 456 :
4040
100 100 100 100 5 5 5 5 5 5 5 5 5 5 5 1
4141
"""
4242

4343

4444
def find_minimum_change(denominations: list, value: int) -> list:
45-
45+
"""
46+
Find the minimum change from the given denominations and value
47+
>>> find_minimum_change([1, 5, 10, 20, 50, 100, 200, 500, 1000,2000], 18745)
48+
[2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 500, 200, 20, 20, 5]
49+
>>> find_minimum_change([1, 2, 5, 10, 20, 50, 100, 500, 2000], 987)
50+
[500, 100, 100, 100, 100, 50, 20, 10, 5, 2]
51+
>>> find_minimum_change([1, 2, 5, 10, 20, 50, 100, 500, 2000], 0)
52+
[]
53+
>>> find_minimum_change([1, 2, 5, 10, 20, 50, 100, 500, 2000], -98)
54+
[]
55+
>>> find_minimum_change([1, 5, 100, 500, 1000], 456)
56+
[100, 100, 100, 100, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]
57+
"""
4658
total_value = int(value)
4759

4860
# Initialize Result

0 commit comments

Comments
 (0)