All problems

Lantern dimmer calibration ignores position between measured points

Level 2 · node · Correctness · Missing relative-position weight in piecewise linear interpolation

Scenario

A fictional lantern exhibition workshop stores measured brightness calibration values at different dimmer positions. The measured points are irregularly spaced, and the control display estimates brightness at unmeasured positions. Values at interval midpoints are correct, but small movements within an interval do not change the estimate.

Requirements

Each lantern has at least one calibration point, with strictly increasing positions. Positions and levels are finite numbers. Return the recorded level at a measured point and a position-dependent linear interpolation between two points. Outside the range, return the nearest endpoint level. Do not modify the original points. Return null for an unregistered lantern.

Acceptance criteria

  • Return the measured level or nearest endpoint level at measured positions and outside the range.
  • Interpolate linearly in proportion to position within an interval, including intervals with decreasing brightness.
  • For multiple intervals use only the two measured points surrounding the requested position.
  • Keep lantern lookups independent, preserve the original measurements, and return null for an unregistered lantern.