๐Ÿ”ฌ Science

Parsing the Log

Stardate 55132.6 ยท UES Magnanimous

Briefing

The contact is transmitting. It is a maintenance log, in a format we recognise, because it is ours: a stardate, a level, and a message, separated by pipe characters. Lt. Skree wants each line broken into its three parts so the analysis suite can read it.

Commander Raghunathan, reading over Skree's shoulder, has pointed at a line whose message reads "pressure|flow mismatch" and asked what happens to that pipe. Skree has gone quiet. It should stay in the message. Only the first two pipes separate fields; anything after them is message, pipes and all.

Mission objectives

ARCHIE checks all five every time you run diagnostics.

  • โ€ขA normal line splits into stardate, level and message
  • โ€ขThe stardate is a number, not text
  • โ€ขA message containing a pipe is kept whole
  • โ€ขLeading and trailing whitespace on the message is trimmed
  • โ€ขA different level and an empty message
Ask Commander Raghunathan for a hint

Split on the pipe, but only twice: Python's split('|', 2), Rust's splitn(3, '|'). Then convert the first part to a number and trim the last one.