Skip to content

Commit 1af4c02

Browse files
Iqrar99cclauss
authored andcommitted
adding doctests on coin_change.py and fixed some typos (TheAlgorithms#1337)
* adding doctests on coin_change.py * fixed some typos * Update lib.py
1 parent f4779bc commit 1af4c02

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

dynamic_programming/coin_change.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88

99

1010
def dp_count(S, m, n):
11+
"""
12+
>>> dp_count([1, 2, 3], 3, 4)
13+
4
14+
>>> dp_count([1, 2, 3], 3, 7)
15+
8
16+
>>> dp_count([2, 5, 3, 6], 4, 10)
17+
5
18+
>>> dp_count([10], 1, 99)
19+
0
20+
>>> dp_count([4, 5, 6], 3, 0)
21+
1
22+
"""
1123

1224
# table[i] represents the number of ways to get to amount i
1325
table = [0] * (n + 1)
@@ -24,7 +36,7 @@ def dp_count(S, m, n):
2436

2537
return table[n]
2638

27-
2839
if __name__ == "__main__":
29-
print(dp_count([1, 2, 3], 3, 4)) # answer 4
30-
print(dp_count([2, 5, 3, 6], 4, 10)) # answer 5
40+
import doctest
41+
42+
doctest.testmod()

0 commit comments

Comments
 (0)