FA-97288 / Recipe scaling and nutrition / Member archive
Macronutrient target splitter: carb from remainder · case 03
Totals drift a few calories from the target because fat rounding is not absorbed.
Case contract
split = [protein%, carb%, fat%] must sum to 100 else "error: split". protein_g = max(half-up kcal*p/400, ceiling(1.6*weight_kg)). Remaining kcal = kcal - 4*protein_g is divided between carb and fat in the ratio c:f; fat_g = half-up(rem*f/(c+f)/9); carb_g = half-up((rem - 9*fat_g)/4). Return [protein_g, carb_g, fat_g].
Why this case matters
Meal-plan generators turn calorie targets into gram targets with a protein floor by body weight.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: carb from remainder | [96, 353, 78] | [96, 354, 78] | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗