๐Ÿ”ฌ Science

Coordinates, With Feeling

Stardate 55135.7 ยท UES Magnanimous

Briefing

The contact is sending its position as a pair of numbers in a string, comma separated, with whatever spacing its transmitter felt like. "12.5, -3.25" is a position. "12.5,-3.25" is the same position. "twelve, three" is not a position, and neither is "12.5" on its own, and Lt. Skree wants those rejected rather than guessed at.

The Captain has asked whether "rejected" means the ship will crash. It means the function returns nothing, and the caller decides. The Captain has said "good" and gone back to looking at the viewscreen, where the contact is now visible as a dot.

Mission objectives

ARCHIE checks all five every time you run diagnostics.

  • โ€ขA well-formed pair with a space after the comma
  • โ€ขThe same pair with no spaces at all
  • โ€ขWords instead of numbers are rejected
  • โ€ขA single number with no comma is rejected
  • โ€ขExtra whitespace around either number is fine
Ask Commander Raghunathan for a hint

Split on the comma; if you do not get exactly two parts, reject. Trim each part and try to convert it to a number; if either fails, reject. Python: catch the ValueError. Rust: parse().ok() and the ? operator inside a function returning Option.