The Long Cold Cup
Stardate 55103.2 ยท UES Magnanimous
Briefing
The beverage replicator on Deck 4 has produced three hundred and forty consecutive cups of lukewarm water. The Captain has raised this at three consecutive staff meetings and is now raising it again, with feeling.
Ensign Tannenbaum has "already looked at it". The situation has since become worse.
Commander Raghunathan traced the fault to a single temperature routine and then did not fix it, on the grounds that it is "a good first one for the new officer". This is Engineering for I am extremely tired.
Mission objectives
ARCHIE checks all five every time you run diagnostics.
- โขBelow the band: 61 degrees reads as too cold
- โขThe lower edge: exactly 82 is already acceptable
- โขComfortably inside: 90 is acceptable
- โขThe upper edge: exactly 96 is still acceptable
- โขAbove the band: 97 makes the Captain happy
Objective
Write brew_report(celsius), which takes a number and returns a string:
"too cold"when the temperature is below 82"acceptable"from 82 to 96 inclusive"the Captain is happy"when it is above 96
Press Run Diagnostics and I will tell you which objectives you actually met.
Objective
Write brew_report(celsius: i32) -> &'static str, which returns:
"too cold"when the temperature is below 82"acceptable"from 82 to 96 inclusive"the Captain is happy"when it is above 96
Write the function only. ARCHIE supplies main.
Press Run Diagnostics and I will tell you which objectives you actually met.
Ask Commander Raghunathan for a hint
Read the specification's word inclusive very carefully, then look at which comparison you used at each edge. Almost every failure here is one character: < where you wanted <=.
Debrief
The replicator is producing coffee at ninety-four degrees. The Captain has been informed and is currently describing it to people who did not ask.
Lt. Skree wishes it noted that the beverage is chemically identical to the previous three hundred and forty, and that the crew's reaction is therefore "sociological rather than thermal". Nobody has replied to this.