FAILURE MAP
← Case archive

FA-97289 / Recipe scaling and nutrition / Member archive

Macronutrient target splitter: carb from remainder · case 04

Totals drift a few calories from the target because fat rounding is not absorbed.

Member previewVariant 4 · 3 implementations · 8 checks per implementation

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 fixture

This sample comes from the broken implementation of a controlled reproducer.

Boundary fixtureActualExpectedOutcome
balanced[150, 200, 67][150, 199, 67]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 ↗