๐Ÿฉบ Sickbay

The Flaky Sensor

Stardate 55164.8 ยท UES Magnanimous

Briefing

The dorsal sensor times out about a third of the time and answers perfectly the rest. Lt. Skree does not want it replaced; Skree wants it retried, up to a set number of attempts, and then given up on honestly. A timeout is worth retrying. A sensor reporting that it is physically broken is not, and retrying it three times just wastes three tries.

Commander Raghunathan adds one thing: the retry must not call the sensor more times than it needs to. If the first read works, that is one call. Not two "to be sure". This is a mission about restraint, and about telling two kinds of failure apart.

Mission objectives

ARCHIE checks all five every time you run diagnostics.

  • โ€ขA read that succeeds first time is called exactly once
  • โ€ขFails twice then succeeds, with three attempts: the value, in three calls
  • โ€ขAlways times out, with three attempts: nothing, in exactly three calls
  • โ€ขOne attempt and a timeout: nothing, in one call
  • โ€ขA broken sensor is not retried
Ask Commander Raghunathan for a hint

Loop up to attempts times. Return the value on success. On a timeout, continue to the next attempt. On any other failure, stop immediately. If the loop ends without a value, return nothing.