๐Ÿ“ฆ Ops

The Crew Directory

Stardate 55131.0 ยท UES Magnanimous

Briefing

Lt. Skree has confirmed the long-range contact is artificial, slow, and not responding to hails. The Captain has asked for every officer of a given rank to report to the bridge, and the crew directory has responded by listing everyone, which is not what he asked and is also, in the Chief's words, "just the crew".

The directory holds each person as a name and a rank. Given a rank, it should return the names of everyone holding it, in the order they appear in the directory. That is the whole request. The Captain has been told it will take five minutes and is standing behind you.

Mission objectives

ARCHIE checks all five every time you run diagnostics.

  • โ€ขEveryone of one rank, in directory order
  • โ€ขA rank held by exactly one person
  • โ€ขA rank held by nobody: an empty result
  • โ€ขNames are returned, not the whole records
  • โ€ขAn empty directory
Ask Commander Raghunathan for a hint

Loop over the records, and for each one whose rank matches, keep the name. In Python that is a comprehension with a condition; in Rust, filter then map.