Which Deck?
Stardate 55106.1 ยท UES Magnanimous
Briefing
Compartments aboard the Maggie are numbered from 1, twelve to a deck. Compartment 1 is on Deck 1, compartment 12 is on Deck 1, and compartment 13 is on Deck 2. This has been true for nineteen years and nobody had to think about it until the turbolift's routing table was "tidied up".
Lt. Skree has now been delivered to the wrong deck four times, has timed each occurrence, and has produced a table. The table shows the lift is wrong exactly at every twelfth compartment. Skree considers this "suspiciously regular for a coincidence". Skree is right.
Mission objectives
ARCHIE checks all five every time you run diagnostics.
- โขCompartment 1 is on Deck 1
- โขCompartment 12, the last on Deck 1, is still on Deck 1
- โขCompartment 13 is on Deck 2
- โขCompartment 24 is on Deck 2
- โขCompartment 100 is on Deck 9
Objective
Write deck_of(compartment): compartments are numbered from 1, twelve per
deck. Return the deck number, also from 1. So compartments 1 to 12 are Deck 1, 13 to 24
are Deck 2, and so on.
Press Run Diagnostics and I will tell you which objectives you actually met.
Objective
Write deck_of(compartment: u32) -> u32: compartments are numbered
from 1, twelve per deck. Return the deck number, also from 1. So compartments 1 to 12
are Deck 1, 13 to 24 are Deck 2, and so on.
Press Run Diagnostics and I will tell you which objectives you actually met.
Ask Commander Raghunathan for a hint
Integer division gets you most of the way, but compartments start at 1, not 0. Try subtracting one before you divide, and adding one after. Then check compartment 12 by hand.
Debrief
The turbolift is delivering people to the deck they asked for. Lt. Skree has updated the table, noted a 100% success rate over eleven trials, and filed it under "resolved, pending long-term observation". Skree does not close things.