The Diagnostic Sweep
Stardate 55129.5 ยท UES Magnanimous
Briefing
The end-of-patrol diagnostic walks every relay in sequence and says what each one needs. Every third relay needs coolant. Every fifth needs plasma. A relay that is both a third and a fifth needs coolant-plasma, and everything else just reports its number. It is the oldest routine on the ship and it has, at some point, stopped doing any of that and started simply counting.
Commander Raghunathan says every engineer in the fleet has written this exact routine as a rite of passage, and that the ones who get relay fifteen wrong the first time are, historically, all of them. Lt. Skree does not see why fifteen would be special. Skree will.
Mission objectives
ARCHIE checks all five every time you run diagnostics.
- โขRelays 1 to 5: number, number, coolant, number, plasma
- โขRelay 15 is coolant-plasma, not coolant and not plasma
- โขRelays 1 to 15 in full
- โขA sweep of zero relays is empty
- โขRelay 30 is also coolant-plasma
Objective
Write sweep(n): return a list of strings for relays 1 to n.
Multiples of 3 give "coolant", multiples of 5 give "plasma",
multiples of both give "coolant-plasma", and everything else gives the
relay number as a string. sweep(0) is an empty list.
Press Run Diagnostics and I will tell you which objectives you actually met.
Objective
Write sweep(n: u32) -> Vec<String>: labels for relays 1 to
n. Multiples of 3 give "coolant", multiples of 5 give
"plasma", multiples of both give "coolant-plasma", and
everything else gives the relay number as a string. sweep(0) is empty.
Press Run Diagnostics and I will tell you which objectives you actually met.
Ask Commander Raghunathan for a hint
Check the both-case first. If you test 'divisible by three' before 'divisible by both', fifteen is caught by the first test and never reaches the right answer. Order of conditions is the whole puzzle.
Debrief
The sweep reports correctly, relay fifteen included, and Commander Raghunathan has signed off the patrol. The Captain has declared the routine "traditional" and asked that it never be replaced.
Routine Patrol complete. Season 3 is open, and there is a signal on long-range sensors that Lt. Skree would like to talk to you about.