Pounds Where Kilograms Should Be — Python Bug Hunt

Modelled on Air Canada Flight 143, the "Gimli Glider" (23 July 1983).

  • Language: Python
  • Layer: Backend
  • Difficulty: Easy
  • Concepts: Units, Math
  • Modelled on: Air Canada · 1983
  • Visible tests: no uplift when the tanks already hold enough; litres convert to kilograms
  • Reward: 50 XP for a complete fix

Briefing

Modelled on Air Canada Flight 143, the "Gimli Glider" (23 July 1983). The Boeing 767's fuel gauges were inoperative, so the fuel on board was measured with drip sticks in litres and converted by hand. The conversion used 1.77 — the density of jet fuel in pounds per litre — where the new metric aircraft needed about 0.8 kilograms per litre. The crew believed they had more than twice the fuel they actually carried; the aircraft ran dry in flight and glided to a landing on a former air-force runway at Gimli, Manitoba. Everyone on board survived.

fuel.py is the fuel sheet: it converts a drip-stick reading into mass and works out how many litres to uplift. Every mass on the sheet is in kilograms.

Fix the conversions.

Bug report

BUG-FUEL-143 · Priority: Critical (safety) · Reported by: line maintenance

  • mass_on_board_kg(litres) = litres * units.KG_PER_LITRE
  • litres_to_uplift(dipstick_litres, required_kg): shortfall_kg = required_kg - mass_on_board_kg(dipstick_litres) 0 when shortfall_kg <= 0, otherwise shortfall_kg / KG_PER_LITRE rounded to the nearest whole litre (an int)

All masses are kilograms; the pounds factor has no place on this sheet.

Observed: 1,000 litres are booked as 1,770 kg of fuel, and the uplift comes out at less than half of what the aircraft needs.

Logs

[fuel-sheet] dipstick=7682 L -> on board 13597 kg (factor 1.77)
[fuel-sheet] required 22300 kg -> uplift 4917 L
[fdr] FUEL QTY LOW both tanks, FL410

The code as shipped

src/fuel/fuel.py (editable)

units = bug_require("./units.py")


def mass_on_board_kg(litres):
    return litres * units.LB_PER_LITRE


def litres_to_uplift(dipstick_litres, required_kg):
    shortfall_kg = required_kg - mass_on_board_kg(dipstick_litres)
    if shortfall_kg <= 0:
        return 0
    return int(round(shortfall_kg / units.LB_PER_LITRE))

Read-only context: src/fuel/units.py.

Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More Python bug hunts.