bilingual-math-code-verification-v1 / code /math_code_009_solution.py
efe-T's picture
Upload folder using huggingface_hub
93237a0 verified
Raw History Blame Contribute Delete
413 Bytes
from fractions import Fraction
candidates = []
for y in range(7):
x = min((14 - y) // 2, 18 - 3 * y)
if x >= 0:
assert 2 * x + y <= 14 and x + 3 * y <= 18
candidates.append((5 * x + 7 * y, x, y))
profit, x, y = max(candidates)
assert Fraction(profit) <= Fraction(274, 5)
result = {"x": x, "y": y, "profit": profit}
import json
print(json.dumps(result, ensure_ascii=False, sort_keys=True))