Skip to content

Commit 7286800

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent ff961fa commit 7286800

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

greedy_methods/minimum_coin_change.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from doctest import testmod
2+
23
"""
34
Test cases:
45
Do you want to enter your denominations ? (Y/N) :N
@@ -40,6 +41,8 @@
4041
Following is minimal change for 456 :
4142
100 100 100 100 5 5 5 5 5 5 5 5 5 5 5 1
4243
"""
44+
45+
4346
def find_minimum_change(denominations: list[int], value: int) -> list[int]:
4447
"""
4548
Find the minimum change from the given denominations and value.
@@ -69,7 +72,7 @@ def find_minimum_change(denominations: list[int], value: int) -> list[int]:
6972

7073
# Initialize Result
7174
answer = []
72-
75+
7376
# Find minimal change using largest denominations first
7477
for denomination in denominations:
7578
while value >= denomination:
@@ -87,12 +90,19 @@ def find_minimum_change(denominations: list[int], value: int) -> list[int]:
8790
denominations = []
8891
value = 0
8992

90-
if input("Do you want to enter your denominations ? (y/n): ").strip().lower() == "y":
93+
if (
94+
input("Do you want to enter your denominations ? (y/n): ").strip().lower()
95+
== "y"
96+
):
9197
try:
92-
n = int(input("Enter the number of denominations you want to add: ").strip())
98+
n = int(
99+
input("Enter the number of denominations you want to add: ").strip()
100+
)
93101
for i in range(n):
94-
denominations.append(int(input(f"Denomination {i+1}: ").strip()))
95-
value = int(input("Enter the change you want to make in Indian Currency: ").strip())
102+
denominations.append(int(input(f"Denomination {i + 1}: ").strip()))
103+
value = int(
104+
input("Enter the change you want to make in Indian Currency: ").strip()
105+
)
96106
except ValueError:
97107
print("Invalid input. Please enter valid numbers.")
98108
exit(1)

0 commit comments

Comments
 (0)