Datasets:
File size: 513 Bytes
93237a0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | from fractions import Fraction
total = Fraction(20)
low, high, target = Fraction(1, 10), Fraction(3, 10), Fraction(18, 100)
y = total * (target - low) / (high - low)
x = total - y
salt = low * x + high * y
remaining = total - 2
assert x >= 0 and y >= 0 and x + y == total
assert salt == total * target
assert remaining - salt == total - salt - 2
result = {"low_kg": str(x), "high_kg": str(y), "final_salt_fraction": str(salt / remaining)}
import json
print(json.dumps(result, ensure_ascii=False, sort_keys=True))
|