Commit
Β·
671b8d8
1
Parent(s):
95902a6
fix(calculator): correct total price calculatio
Browse files
app.py
CHANGED
@@ -156,7 +156,7 @@ def calculator(currency, budget, strategy, extra_rate, *amount):
|
|
156 |
|
157 |
# Final solution processing
|
158 |
solution = []
|
159 |
-
|
160 |
# total_count = 0
|
161 |
|
162 |
if model.getStatus() == "optimal":
|
@@ -165,13 +165,13 @@ def calculator(currency, budget, strategy, extra_rate, *amount):
|
|
165 |
solution.append(
|
166 |
f"{plants_names[i]} ({sold_prices[i]} {currency}): {v}\n"
|
167 |
)
|
168 |
-
|
169 |
# total_count += v
|
170 |
|
171 |
if optimal_total_value == budget:
|
172 |
-
return f"Great! Found a combination of items with a total value equal to the budget ({budget} {currency}).π\n\n{''.join(solution)}\nTotal value: {int(
|
173 |
|
174 |
-
return f"Oops! {int(budget - optimal_total_value)} {currency} short of the target value ({budget} {currency}).π£\n\n{''.join(solution)}\nTotal value: {int(
|
175 |
|
176 |
return "No solution found for the second optimization!"
|
177 |
|
|
|
156 |
|
157 |
# Final solution processing
|
158 |
solution = []
|
159 |
+
total_price = 0
|
160 |
# total_count = 0
|
161 |
|
162 |
if model.getStatus() == "optimal":
|
|
|
165 |
solution.append(
|
166 |
f"{plants_names[i]} ({sold_prices[i]} {currency}): {v}\n"
|
167 |
)
|
168 |
+
total_price += v * sold_prices[i]
|
169 |
# total_count += v
|
170 |
|
171 |
if optimal_total_value == budget:
|
172 |
+
return f"Great! Found a combination of items with a total value equal to the budget ({budget} {currency}).π\n\n{''.join(solution)}\nTotal value: {int(total_price)} {currency}\n" # Count: {int(model.getObjVal())}
|
173 |
|
174 |
+
return f"Oops! {int(budget - optimal_total_value)} {currency} short of the target value ({budget} {currency}).π£\n\n{''.join(solution)}\nTotal value: {int(total_price)} {currency}\n" # Count: {int(model.getObjVal())}
|
175 |
|
176 |
return "No solution found for the second optimization!"
|
177 |
|