Mars Rovers VI: The Grid Viz Problem
This is part of the Mars Rovers series.
Wouldn’t you like to see those rovers’ tracks instead of just "2 3 W" strings and the like?
Well, I would. So as soon as I finished writing my solutions, I formulated the following extension to the problem.
The Mars Rovers’ Grid Viz Problem
The Space Agency now wants to visualize what parts of the grid their squad of robotic rovers would cover. As it happens, no fancy GUIs should be involved: they want text.
Using the exact same input format as the original problem, write code that can create a sequence of plaintext grids, one per rover, as in the example below:
INPUT
5 5 1 2 N LMLMLMLMM 3 3 E MMRMMRMRRM
OUTPUT
=====================
· · · · · ·
· · · · · ·
· N · · · ·
│
·───1 · · · ·
│ │
·───· · · · ·
· · · · · ·
=====================
· · · · · ·
· · · · · ·
· · · 2───·───·
│
· · · · · ·
│
· · · · ·───E
· · · · · ·
=====================
Notes:
- The starting point has the rover’s number, as implied by the sequence of rover data (1, 2, 3...).
- The end point has the rover’s final heading.
- No more than nine rovers will be deployed at any one mission.
- The printed tracks don’t track information about direction or repetitions.
- For example, the square shown for Rover 1 is covered counterclockwise and only once. But had it been covered clockwise three times, it’d have looked just the same — and that’s ok.
- For example, the square shown for Rover 1 is covered counterclockwise and only once. But had it been covered clockwise three times, it’d have looked just the same — and that’s ok.
- If the rover starts and ends at the same place, print its heading (in this case, then, its number won’t show up).
- Your output for the sample INPUT should be exactly the same as the OUTPUT above (modulo trailing whitespace, whose presence or absence isn’t important here).
See next
After I wrote the above, I sat down to solve it. So once you’re satisfied with your own solution(s), go ahead and have a look at mine.
My spoilers start next, with The Grid Viz Design — so only click on it when you’re ready.
The Series
Mars Rovers I: The Problem
Mars Rovers II: The Design
Mars Rovers III: The Solutions — Clojure
Mars Rovers IV: The Solutions — Emacs Lisp
Mars Rovers V: The Solutions — Bash
Mars Rovers VI: The Grid Viz Problem
Mars Rovers VII: The Grid Viz Design
Mars Rovers VIII: The Grid Viz Solutions — Clojure
Mars Rovers IX: The Grid Viz Solutions — Emacs Lisp
Mars Rovers X: The Grid Viz Solutions — Bash
📆 2026-W16-7📆 2026-04-19