Space mission log analysis

The longest completed Mars mission lasted 1,629 days. Its security code is XRT-421-ZQP.

The command

This command downloads the source log, trims spacing around fields, requires exactly eight fields, and compares durations as numbers. It prints the security code.

curl -fsSL https://raw.githubusercontent.com/warpdotdev/hiring-challenge/refs/heads/main/space_missions.log |
awk -F '|' '
  function trim(s) { gsub(/^[[:space:]]+|[[:space:]]+$/, "", s); return s }
  NF == 8 && trim($3) == "Mars" && trim($4) == "Completed" {
    days = trim($6)
    if (days ~ /^[0-9]+$/ && days + 0 > max) {
      max = days + 0
      code = trim($8)
    }
  }
  END { print code }
'

Output: XRT-421-ZQP

Data Validation

Both charts use the 975 eight-field records whose destination is Mars, status is Completed, and duration is numeric. Surrounding spaces are removed before measuring the duration’s digit count. A separate scan found no Mars/Completed candidates excluded by field count or a nonnumeric duration.

Histogram of 975 completed Mars mission durations in 200-day bins. Most are under 600 days; one is between 1,600 and 1,799 days.
Mission durations in 200-day bins. The count axis is logarithmic so rare long missions remain visible. The orange bar contains the winner.
Histogram of trimmed duration digit counts: 186 missions have 2 digits, 775 have 3, and 14 have 4. The orange 4-digit bar contains the winner.
Length of the duration value after trimming: 186 have 2 digits, 775 have 3, and 14 have 4. The orange bar contains the winner's 1629.