FA-63975 / Medication dosing calculations / Member archive
Tablet strength selection with scored halves: candidate ranking · case 05
Two tablets of a smaller strength are chosen over one and a half of a larger strength giving the same dose.
Case contract
Input {target_mg, strengths, scored (strengths that may be halved), tol_pct}. For each strength s: step = s/2 if s is scored else s; units = target/step rounded half-up (skip if 0); dose = units*step; tablets = dose/s (skip if more than 4 tablets); keep only |dose-target|*100 <= tol_pct*target. Prefer smallest absolute error, then fewest physical tablets (ceil of tablets), then the largest strength. Return {status OK, strength, tablets, dose_mg} or {status NO_MATCH}.
Why this case matters
Dispensing systems translate an ordered dose into real tablets; halving rules, tolerance, and ranking are separate decisions.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| equal error prefers larger strength | {"dose_mg": 30.0, "status": "OK", "strength": 15, "tablets": 2.0} | {"dose_mg": 30.0, "status": "OK", "strength": 20, "tablets": 1.5} | 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 ↗