๐Ÿ”ฌ Science

The Loudest Three

Stardate 55147.7 ยท UES Magnanimous

Briefing

The pattern in the other ship's log is a set of spikes. Lt. Skree wants the largest few readings from any stretch of the log, largest first, and wants the request to be one expression, because Skree has been reading about iterator chains and has decided they are "the correct shape for thoughts".

The Captain, passing, asked whether the spikes were dangerous. Skree said they were "nineteen years old". The Captain said that was not an answer. Skree agreed that it was not, and went back to the console.

Mission objectives

ARCHIE checks all five every time you run diagnostics.

  • โ€ขThe three largest, largest first
  • โ€ขTies are kept, not collapsed
  • โ€ขFewer readings than asked for: all of them, largest first
  • โ€ขAsking for zero gives nothing
  • โ€ขThe input is not modified
Ask Commander Raghunathan for a hint

Sort a copy in descending order and take the first n. Python: sorted(readings, reverse=True)[:n]. Rust: clone into a Vec, sort_unstable_by(|a, b| b.cmp(a)), truncate(n). The last objective is why it must be a copy.