FA-66106 / Aviation weight and balance / Open access
CG divided from the reduced moment · case 01
The loaded CG is reported near zero inches.
ROOT CAUSE
The CG uses the reduced (divided by 1000) moment rather than the full moment.
VERIFIED REPAIR
Compute CG from the unreduced moment divided by total weight.
Unsuccessful approach: Scaling the rounded reduced moment back up reintroduces rounding error of up to 5 lb-in into the CG.
Case contract
Input [[quantity, 'kg'|'lb', arm, 'in'|'cm'|'mm']]. Convert to lb (1 kg = 2.20462 lb) and inches (2.54 cm, 25.4 mm per inch); other units -> 'ERR_UNIT'; total weight <= 0 -> 'ERR_WEIGHT'. Return [weight lb r1, reduced moment (lb-in/1000) r2, CG in r2 computed from the unreduced moment].
Why this case matters
Imported aircraft documentation mixes metric and imperial units; reduced moments (moment/1000) are a charting convenience and must not feed the CG division.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
wf = {'kg': 2.20462, 'lb': 1.0}
af = {'in': 1.0, 'cm': 1 / 2.54, 'mm': 1 / 25.4}
w = 0.0
m = 0.0
for q, wu, arm, au in x:
if wu not in wf or au not in af: return 'ERR_UNIT'
lb = q * wf[wu]
w += lb
m += lb * arm * af[au]
if w <= 0: return 'ERR_WEIGHT'
return [round(w, 1), round(m / 1000, 2), round(round(m / 1000, 2) / w, 2)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mixed kg and cm', [[81.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [348.6, 12.97, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3510.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 498.38, 150.71]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [120.0, 'lb', 48.0, 'in']], [2110.0, 83.02, 39.35]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[10.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 251.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 560.51, 97.91]], ['sampled case 1', [[1412.5, 'kg', 3138.2, 'cm'], [645.7, 'lb', 3313.7, 'cm'], [780.8, 'lb', 1136.3, 'cm'], [548.1, 'kg', 3196.1, 'cm'], [708.5, 'kg', 4627.1, 'in']], [7310.9, 13786.98, 1885.82]], ['sampled case 2', [[446.5, 'lb', 1614.2, 'cm'], [1166.3, 'lb', 934.4, 'mm'], [1321.5, 'lb', 2983.7, 'in'], [1133.4, 'lb', 4571.3, 'mm']], [4067.7, 4473.6, 1099.79]], ['sampled case 3', [[880.0, 'kg', 2334.3, 'mm']], [1940.1, 178.3, 91.9]], ['regression: CG from reduced moment', [[394.5, 'lb', 719.5, 'in']], [394.5, 283.84, 719.5]]], [['mixed kg and cm', [[82.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [350.8, 13.05, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3520.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 499.42, 151.02]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [240.0, 'lb', 48.0, 'in']], [2230.0, 88.78, 39.81]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[20.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 252.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 562.68, 98.28]], ['sampled case 1', [[451.1, 'lb', 2563.5, 'mm'], [525.2, 'kg', 1580.7, 'in'], [1447.9, 'kg', 4822.5, 'cm'], [324.3, 'kg', 4534.3, 'in']], [5516.0, 11178.14, 2026.5]], ['sampled case 2', [[741.8, 'lb', 489.9, 'mm']], [741.8, 14.31, 19.29]], ['sampled case 3', [[65.8, 'lb', 769.9, 'cm'], [1474.8, 'kg', 2706.1, 'mm'], [1498.3, 'kg', 2769.1, 'cm']], [6620.4, 3967.46, 599.28]]], [['mixed kg and cm', [[83.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [353.0, 13.13, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3530.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 500.47, 151.34]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [360.0, 'lb', 48.0, 'in']], [2350.0, 94.54, 40.23]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[30.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 253.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 564.85, 98.66]], ['sampled case 1', [[587.7, 'lb', 751.0, 'in'], [1481.3, 'kg', 2071.3, 'mm'], [1260.8, 'lb', 3264.1, 'in']], [5114.2, 4823.05, 943.07]], ['sampled case 2', [[1420.4, 'lb', 62.7, 'in'], [744.7, 'lb', 3096.0, 'cm'], [1460.6, 'lb', 2357.4, 'in'], [784.7, 'kg', 1562.0, 'mm']], [5355.7, 4546.38, 848.89]], ['sampled case 3', [[927.8, 'lb', 3339.6, 'mm'], [96.5, 'lb', 2857.2, 'in']], [1024.3, 397.71, 388.27]]], [['mixed kg and cm', [[84.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [355.2, 13.22, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3540.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 501.51, 151.65]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [480.0, 'lb', 48.0, 'in']], [2470.0, 100.3, 40.61]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[40.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 254.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 567.02, 99.04]], ['sampled case 1', [[845.6, 'lb', 549.1, 'mm'], [706.7, 'lb', 4259.5, 'cm'], [418.1, 'lb', 941.4, 'in'], [300.5, 'lb', 701.4, 'in']], [2270.9, 1807.76, 796.06]], ['sampled case 2', [[672.3, 'lb', 4546.6, 'cm'], [811.4, 'kg', 2178.7, 'mm'], [1336.5, 'kg', 2678.4, 'cm'], [437.9, 'lb', 3587.0, 'in']], [5845.5, 6034.62, 1032.35]], ['sampled case 3', [[932.7, 'lb', 1924.2, 'in'], [707.5, 'lb', 1732.9, 'cm']], [1640.2, 2277.39, 1388.48]]], [['mixed kg and cm', [[85.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [357.4, 13.3, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3550.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 502.55, 151.97]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [600.0, 'lb', 48.0, 'in']], [2590.0, 106.06, 40.95]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[50.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 255.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 569.19, 99.42]], ['sampled case 1', [[443.4, 'lb', 3757.6, 'mm'], [1247.8, 'lb', 3883.6, 'cm'], [863.0, 'kg', 1577.0, 'in']], [3593.8, 4973.83, 1384.01]], ['sampled case 2', [[1022.3, 'kg', 4134.6, 'cm'], [1227.6, 'kg', 1189.8, 'mm']], [4960.2, 3795.47, 765.19]], ['sampled case 3', [[516.4, 'kg', 3268.8, 'in'], [1320.8, 'kg', 2685.1, 'cm'], [1128.7, 'kg', 3910.9, 'cm'], [295.8, 'kg', 1659.2, 'cm'], [1025.6, 'lb', 579.9, 'cm']], [8216.4, 11291.14, 1374.22]], ['regression: CG from reduced moment', [[1026.8, 'lb', 537.4, 'in'], [882.1, 'lb', 1438.3, 'in'], [108.9, 'kg', 2100.3, 'cm'], [1314.8, 'lb', 3568.5, 'cm'], [1474.3, 'lb', 3755.8, 'in']], [4938.1, 9403.42, 1904.26]]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| mixed kg and cm | [348.6, 12.97, 0.04] | [348.6, 12.97, 37.21] | Failed |
| millimetre arms | [3306.9, 498.38, 0.15] | [3306.9, 498.38, 150.71] | Failed |
| all imperial | [2110.0, 83.02, 0.04] | [2110.0, 83.02, 39.35] | Failed |
| unknown weight unit | ERR_UNIT | ERR_UNIT | Passed |
| unknown arm unit | ERR_UNIT | ERR_UNIT | Passed |
| removal leaves nothing | ERR_WEIGHT | ERR_WEIGHT | Passed |
| heavy kg load | [5725.0, 560.51, 0.1] | [5725.0, 560.51, 97.91] | Failed |
| sampled case 1 | [7310.9, 13786.98, 1.89] | [7310.9, 13786.98, 1885.82] | Failed |
| sampled case 2 | [4067.7, 4473.6, 1.1] | [4067.7, 4473.6, 1099.79] | Failed |
| sampled case 3 | [1940.1, 178.3, 0.09] | [1940.1, 178.3, 91.9] | Failed |
| regression: CG from reduced moment | [394.5, 283.84, 0.72] | [394.5, 283.84, 719.5] | Failed |
SHA-256 / 462742d305a15835b22f9a8a4b77c1e865fd79eb070296659c79cc80266a665e
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
wf = {'kg': 2.20462, 'lb': 1.0}
af = {'in': 1.0, 'cm': 1 / 2.54, 'mm': 1 / 25.4}
w = 0.0
m = 0.0
for q, wu, arm, au in x:
if wu not in wf or au not in af: return 'ERR_UNIT'
lb = q * wf[wu]
w += lb
m += lb * arm * af[au]
if w <= 0: return 'ERR_WEIGHT'
return [round(w, 1), round(m / 1000, 2), round(round(m / 1000, 2) * 1000 / w, 2)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mixed kg and cm', [[81.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [348.6, 12.97, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3510.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 498.38, 150.71]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [120.0, 'lb', 48.0, 'in']], [2110.0, 83.02, 39.35]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[10.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 251.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 560.51, 97.91]], ['sampled case 1', [[1412.5, 'kg', 3138.2, 'cm'], [645.7, 'lb', 3313.7, 'cm'], [780.8, 'lb', 1136.3, 'cm'], [548.1, 'kg', 3196.1, 'cm'], [708.5, 'kg', 4627.1, 'in']], [7310.9, 13786.98, 1885.82]], ['sampled case 2', [[446.5, 'lb', 1614.2, 'cm'], [1166.3, 'lb', 934.4, 'mm'], [1321.5, 'lb', 2983.7, 'in'], [1133.4, 'lb', 4571.3, 'mm']], [4067.7, 4473.6, 1099.79]], ['sampled case 3', [[880.0, 'kg', 2334.3, 'mm']], [1940.1, 178.3, 91.9]], ['regression: CG from reduced moment', [[394.5, 'lb', 719.5, 'in']], [394.5, 283.84, 719.5]]], [['mixed kg and cm', [[82.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [350.8, 13.05, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3520.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 499.42, 151.02]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [240.0, 'lb', 48.0, 'in']], [2230.0, 88.78, 39.81]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[20.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 252.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 562.68, 98.28]], ['sampled case 1', [[451.1, 'lb', 2563.5, 'mm'], [525.2, 'kg', 1580.7, 'in'], [1447.9, 'kg', 4822.5, 'cm'], [324.3, 'kg', 4534.3, 'in']], [5516.0, 11178.14, 2026.5]], ['sampled case 2', [[741.8, 'lb', 489.9, 'mm']], [741.8, 14.31, 19.29]], ['sampled case 3', [[65.8, 'lb', 769.9, 'cm'], [1474.8, 'kg', 2706.1, 'mm'], [1498.3, 'kg', 2769.1, 'cm']], [6620.4, 3967.46, 599.28]]], [['mixed kg and cm', [[83.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [353.0, 13.13, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3530.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 500.47, 151.34]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [360.0, 'lb', 48.0, 'in']], [2350.0, 94.54, 40.23]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[30.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 253.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 564.85, 98.66]], ['sampled case 1', [[587.7, 'lb', 751.0, 'in'], [1481.3, 'kg', 2071.3, 'mm'], [1260.8, 'lb', 3264.1, 'in']], [5114.2, 4823.05, 943.07]], ['sampled case 2', [[1420.4, 'lb', 62.7, 'in'], [744.7, 'lb', 3096.0, 'cm'], [1460.6, 'lb', 2357.4, 'in'], [784.7, 'kg', 1562.0, 'mm']], [5355.7, 4546.38, 848.89]], ['sampled case 3', [[927.8, 'lb', 3339.6, 'mm'], [96.5, 'lb', 2857.2, 'in']], [1024.3, 397.71, 388.27]]], [['mixed kg and cm', [[84.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [355.2, 13.22, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3540.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 501.51, 151.65]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [480.0, 'lb', 48.0, 'in']], [2470.0, 100.3, 40.61]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[40.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 254.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 567.02, 99.04]], ['sampled case 1', [[845.6, 'lb', 549.1, 'mm'], [706.7, 'lb', 4259.5, 'cm'], [418.1, 'lb', 941.4, 'in'], [300.5, 'lb', 701.4, 'in']], [2270.9, 1807.76, 796.06]], ['sampled case 2', [[672.3, 'lb', 4546.6, 'cm'], [811.4, 'kg', 2178.7, 'mm'], [1336.5, 'kg', 2678.4, 'cm'], [437.9, 'lb', 3587.0, 'in']], [5845.5, 6034.62, 1032.35]], ['sampled case 3', [[932.7, 'lb', 1924.2, 'in'], [707.5, 'lb', 1732.9, 'cm']], [1640.2, 2277.39, 1388.48]]], [['mixed kg and cm', [[85.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [357.4, 13.3, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3550.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 502.55, 151.97]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [600.0, 'lb', 48.0, 'in']], [2590.0, 106.06, 40.95]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[50.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 255.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 569.19, 99.42]], ['sampled case 1', [[443.4, 'lb', 3757.6, 'mm'], [1247.8, 'lb', 3883.6, 'cm'], [863.0, 'kg', 1577.0, 'in']], [3593.8, 4973.83, 1384.01]], ['sampled case 2', [[1022.3, 'kg', 4134.6, 'cm'], [1227.6, 'kg', 1189.8, 'mm']], [4960.2, 3795.47, 765.19]], ['sampled case 3', [[516.4, 'kg', 3268.8, 'in'], [1320.8, 'kg', 2685.1, 'cm'], [1128.7, 'kg', 3910.9, 'cm'], [295.8, 'kg', 1659.2, 'cm'], [1025.6, 'lb', 579.9, 'cm']], [8216.4, 11291.14, 1374.22]], ['regression: CG from reduced moment', [[1026.8, 'lb', 537.4, 'in'], [882.1, 'lb', 1438.3, 'in'], [108.9, 'kg', 2100.3, 'cm'], [1314.8, 'lb', 3568.5, 'cm'], [1474.3, 'lb', 3755.8, 'in']], [4938.1, 9403.42, 1904.26]]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| mixed kg and cm | [348.6, 12.97, 37.21] | [348.6, 12.97, 37.21] | Passed |
| millimetre arms | [3306.9, 498.38, 150.71] | [3306.9, 498.38, 150.71] | Passed |
| all imperial | [2110.0, 83.02, 39.35] | [2110.0, 83.02, 39.35] | Passed |
| unknown weight unit | ERR_UNIT | ERR_UNIT | Passed |
| unknown arm unit | ERR_UNIT | ERR_UNIT | Passed |
| removal leaves nothing | ERR_WEIGHT | ERR_WEIGHT | Passed |
| heavy kg load | [5725.0, 560.51, 97.91] | [5725.0, 560.51, 97.91] | Passed |
| sampled case 1 | [7310.9, 13786.98, 1885.82] | [7310.9, 13786.98, 1885.82] | Passed |
| sampled case 2 | [4067.7, 4473.6, 1099.79] | [4067.7, 4473.6, 1099.79] | Passed |
| sampled case 3 | [1940.1, 178.3, 91.9] | [1940.1, 178.3, 91.9] | Passed |
| regression: CG from reduced moment | [394.5, 283.84, 719.49] | [394.5, 283.84, 719.5] | Failed |
SHA-256 / 45e83c455d8e7bab436cd176ce24e04782275dc2470e8d3c8df0a0039bd20fee
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
wf = {'kg': 2.20462, 'lb': 1.0}
af = {'in': 1.0, 'cm': 1 / 2.54, 'mm': 1 / 25.4}
w = 0.0
m = 0.0
for q, wu, arm, au in x:
if wu not in wf or au not in af: return 'ERR_UNIT'
lb = q * wf[wu]
w += lb
m += lb * arm * af[au]
if w <= 0: return 'ERR_WEIGHT'
return [round(w, 1), round(m / 1000, 2), round(m / w, 2)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mixed kg and cm', [[81.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [348.6, 12.97, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3510.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 498.38, 150.71]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [120.0, 'lb', 48.0, 'in']], [2110.0, 83.02, 39.35]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[10.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 251.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 560.51, 97.91]], ['sampled case 1', [[1412.5, 'kg', 3138.2, 'cm'], [645.7, 'lb', 3313.7, 'cm'], [780.8, 'lb', 1136.3, 'cm'], [548.1, 'kg', 3196.1, 'cm'], [708.5, 'kg', 4627.1, 'in']], [7310.9, 13786.98, 1885.82]], ['sampled case 2', [[446.5, 'lb', 1614.2, 'cm'], [1166.3, 'lb', 934.4, 'mm'], [1321.5, 'lb', 2983.7, 'in'], [1133.4, 'lb', 4571.3, 'mm']], [4067.7, 4473.6, 1099.79]], ['sampled case 3', [[880.0, 'kg', 2334.3, 'mm']], [1940.1, 178.3, 91.9]], ['regression: CG from reduced moment', [[394.5, 'lb', 719.5, 'in']], [394.5, 283.84, 719.5]]], [['mixed kg and cm', [[82.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [350.8, 13.05, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3520.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 499.42, 151.02]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [240.0, 'lb', 48.0, 'in']], [2230.0, 88.78, 39.81]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[20.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 252.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 562.68, 98.28]], ['sampled case 1', [[451.1, 'lb', 2563.5, 'mm'], [525.2, 'kg', 1580.7, 'in'], [1447.9, 'kg', 4822.5, 'cm'], [324.3, 'kg', 4534.3, 'in']], [5516.0, 11178.14, 2026.5]], ['sampled case 2', [[741.8, 'lb', 489.9, 'mm']], [741.8, 14.31, 19.29]], ['sampled case 3', [[65.8, 'lb', 769.9, 'cm'], [1474.8, 'kg', 2706.1, 'mm'], [1498.3, 'kg', 2769.1, 'cm']], [6620.4, 3967.46, 599.28]]], [['mixed kg and cm', [[83.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [353.0, 13.13, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3530.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 500.47, 151.34]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [360.0, 'lb', 48.0, 'in']], [2350.0, 94.54, 40.23]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[30.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 253.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 564.85, 98.66]], ['sampled case 1', [[587.7, 'lb', 751.0, 'in'], [1481.3, 'kg', 2071.3, 'mm'], [1260.8, 'lb', 3264.1, 'in']], [5114.2, 4823.05, 943.07]], ['sampled case 2', [[1420.4, 'lb', 62.7, 'in'], [744.7, 'lb', 3096.0, 'cm'], [1460.6, 'lb', 2357.4, 'in'], [784.7, 'kg', 1562.0, 'mm']], [5355.7, 4546.38, 848.89]], ['sampled case 3', [[927.8, 'lb', 3339.6, 'mm'], [96.5, 'lb', 2857.2, 'in']], [1024.3, 397.71, 388.27]]], [['mixed kg and cm', [[84.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [355.2, 13.22, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3540.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 501.51, 151.65]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [480.0, 'lb', 48.0, 'in']], [2470.0, 100.3, 40.61]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[40.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 254.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 567.02, 99.04]], ['sampled case 1', [[845.6, 'lb', 549.1, 'mm'], [706.7, 'lb', 4259.5, 'cm'], [418.1, 'lb', 941.4, 'in'], [300.5, 'lb', 701.4, 'in']], [2270.9, 1807.76, 796.06]], ['sampled case 2', [[672.3, 'lb', 4546.6, 'cm'], [811.4, 'kg', 2178.7, 'mm'], [1336.5, 'kg', 2678.4, 'cm'], [437.9, 'lb', 3587.0, 'in']], [5845.5, 6034.62, 1032.35]], ['sampled case 3', [[932.7, 'lb', 1924.2, 'in'], [707.5, 'lb', 1732.9, 'cm']], [1640.2, 2277.39, 1388.48]]], [['mixed kg and cm', [[85.0, 'kg', 95.0, 'cm'], [170.0, 'lb', 37.0, 'in']], [357.4, 13.3, 37.21]], ['millimetre arms', [[1200.0, 'kg', 3550.0, 'mm'], [300.0, 'kg', 5100.0, 'mm']], [3306.9, 502.55, 151.97]], ['all imperial', [[1650.0, 'lb', 39.2, 'in'], [340.0, 'lb', 37.0, 'in'], [600.0, 'lb', 48.0, 'in']], [2590.0, 106.06, 40.95]], ['unknown weight unit', [[10.0, 'st', 50.0, 'in']], 'ERR_UNIT'], ['unknown arm unit', [[50.0, 'kg', 2.0, 'm']], 'ERR_UNIT'], ['removal leaves nothing', [[20.0, 'kg', 100.0, 'cm'], [-50.0, 'lb', 39.37, 'in']], 'ERR_WEIGHT'], ['heavy kg load', [[2500.0, 'kg', 255.0, 'cm'], [90.0, 'kg', 180.0, 'cm'], [15.0, 'lb', 120.0, 'in']], [5725.0, 569.19, 99.42]], ['sampled case 1', [[443.4, 'lb', 3757.6, 'mm'], [1247.8, 'lb', 3883.6, 'cm'], [863.0, 'kg', 1577.0, 'in']], [3593.8, 4973.83, 1384.01]], ['sampled case 2', [[1022.3, 'kg', 4134.6, 'cm'], [1227.6, 'kg', 1189.8, 'mm']], [4960.2, 3795.47, 765.19]], ['sampled case 3', [[516.4, 'kg', 3268.8, 'in'], [1320.8, 'kg', 2685.1, 'cm'], [1128.7, 'kg', 3910.9, 'cm'], [295.8, 'kg', 1659.2, 'cm'], [1025.6, 'lb', 579.9, 'cm']], [8216.4, 11291.14, 1374.22]], ['regression: CG from reduced moment', [[1026.8, 'lb', 537.4, 'in'], [882.1, 'lb', 1438.3, 'in'], [108.9, 'kg', 2100.3, 'cm'], [1314.8, 'lb', 3568.5, 'cm'], [1474.3, 'lb', 3755.8, 'in']], [4938.1, 9403.42, 1904.26]]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| mixed kg and cm | [348.6, 12.97, 37.21] | [348.6, 12.97, 37.21] | Passed |
| millimetre arms | [3306.9, 498.38, 150.71] | [3306.9, 498.38, 150.71] | Passed |
| all imperial | [2110.0, 83.02, 39.35] | [2110.0, 83.02, 39.35] | Passed |
| unknown weight unit | ERR_UNIT | ERR_UNIT | Passed |
| unknown arm unit | ERR_UNIT | ERR_UNIT | Passed |
| removal leaves nothing | ERR_WEIGHT | ERR_WEIGHT | Passed |
| heavy kg load | [5725.0, 560.51, 97.91] | [5725.0, 560.51, 97.91] | Passed |
| sampled case 1 | [7310.9, 13786.98, 1885.82] | [7310.9, 13786.98, 1885.82] | Passed |
| sampled case 2 | [4067.7, 4473.6, 1099.79] | [4067.7, 4473.6, 1099.79] | Passed |
| sampled case 3 | [1940.1, 178.3, 91.9] | [1940.1, 178.3, 91.9] | Passed |
| regression: CG from reduced moment | [394.5, 283.84, 719.5] | [394.5, 283.84, 719.5] | Passed |
SHA-256 / 909e03c07a136f9d6b02e47672f51b0f5f0c41465d1da7e08a95ca024dc38521
Verification & scope
A deterministic toy loading model with stipulated constants; it is not an approved aircraft flight manual procedure and makes no claim of regulatory conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:47:40.196931+00:00.
Case digest / 51252ba24fbf2e4eb82d488905b624b716055331637bde16710a1f05320b2e05