Auto urgent commit.

This commit is contained in:
2025-04-09 09:42:24 +02:00
parent e9b71d925e
commit b6f8941c53
2 changed files with 32 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
def machine_bruteforce(price, enter, money_allowed):
assert (
enter >= price
), "The entered amount must be greater than or equal to the price"
change = enter - price
if change == 0:
return [[]]
results = []
def brute(current_combination, total):
if total == change:
results.append(current_combination.copy())
return
if total > change:
return
for coin in money_allowed:
current_combination.append(coin)
brute(current_combination, total + coin)
current_combination.pop()
brute([], 0)
return results