Add university content

This commit is contained in:
2025-09-26 11:16:23 +02:00
parent 45054aef03
commit 76bbd2e5ad
125 changed files with 230 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

View File

@@ -0,0 +1,8 @@
def change_render(p, price, given_money):
change = given_money - price
if change < 0:
raise Exception("the price cannot be greater than the given money")
else:
pos_m = [] # En gros ça donne les pièce inférieur au montant de change
pos_m = sorted([i for i in p if i <= change])
pos_t = []