๐Ÿ”ฌ Science

The Two Logs

Stardate 55169.5 ยท UES Magnanimous

Briefing

Lt. Skree wants the two logs read properly, start to finish, by a program rather than by Skree, because Skree has been reading them for six days and has started to see the pattern on the inside of Skree's eyelids.

Parse the log text into entries, ignoring blank lines and comment lines beginning with a hash. Find the first index where the two logs disagree, if they ever do. Count entries by level. Return everything after a given stardate. Four functions, all of them things you have built pieces of before, assembled into one tool. The Captain has asked what comes after the divergence in the other log. Skree has said "us, I think".

Mission objectives

ARCHIE checks all eight every time you run diagnostics.

  • โ€ขparse_log: entries from lines, stardate as a number
  • โ€ขparse_log: blank lines and # comments are skipped
  • โ€ขfirst_divergence: the index of the first differing entry
  • โ€ขfirst_divergence: identical logs give nothing
  • โ€ขfirst_divergence: a shorter log diverges at its own end
  • โ€ขcount_levels: a count per level, sorted by level
  • โ€ขafter: entries strictly after a stardate, in order
  • โ€ขafter: nothing after the last stardate
Ask Commander Raghunathan for a hint

Reuse the Season 3 parser for one line. first_divergence is a zip and a comparison, plus a length check for the shorter-log case. count_levels is a dictionary or map. Read each objective's wording for 'strictly'.

๐Ÿš€ Away mission

Away mission: point the parser at a real file. Write a small tool that takes two log paths on the command line, prints the first divergence with a few lines of context from each side, and a level summary for both. Add --after STARDATE. Then write three tests for first_divergence, including the shorter-log case, because that is the one you will get wrong when you refactor it.