My solution to ThoughtWorks' mars rover problem