๐Ÿ“ฆ Ops

The Most Requested Item

Stardate 55125.6 ยท UES Magnanimous

Briefing

Chief T'Kala would like to know which item is requisitioned most often, so Stores can keep more of it. The naive answer is "plasma couplings", because of the Tannenbaum incident, but the Chief wants the count done properly, over the real log, with the Ensign's eleven duplicates already removed.

Where two items tie, she wants the one that comes first alphabetically, so the answer is stable and nobody argues. Where the log is empty, she wants nothing, rather than a guess. Commander Raghunathan has predicted the answer will be "coffee filters" and has put money on it.

Mission objectives

ARCHIE checks all five every time you run diagnostics.

  • โ€ขThe most frequent item in a mixed log
  • โ€ขA tie goes to the alphabetically first item
  • โ€ขA single-entry log
  • โ€ขEvery entry the same
  • โ€ขAn empty log: nothing, not a guess
Ask Commander Raghunathan for a hint

Count each item into a dictionary or map first, then pick the winner. For the tie rule, compare on (count, name) rather than count alone: highest count, and among equals, the smallest name.