Ad

Introduction

My place of work changes all the time, and my Nokia Brick doesn't support Google Maps.
I need to find the fastest way to work through a variety of different locations - and I need user-friendly instructions that can be read out, since I can't look away from the road.

Your job in this kumite is to take an array (the map), and work out the fastest way from the hotel ('h'), to the office ('o') through the streets given. Driveable roads are represented by blankspace, and the map (and roads) are outlined by dashes ('-'). Then, compute some directions to take me there!

IF THERE IS NO POSSIBLE WAY TO GET TO THE OFFICE, RETURN "dont bother"

In the words of a great poet,

"The journey, not the arrival, matters." - T.S. Eliot

Tips

  • You can assume that when I start, I am facing north.
  • You can assume that there will be a route faster than the others.
  • You can assume that the arrays will be the same length.
  • I must travel onto the hotel.
  • I will start on the outline of the map - moving into the map is an included step.
  • You cannot assume that the I will start at the bottom of the map.

Result

You must return an array with strings inside, that can only be of the following:

"turn left", "turn right", "drive forward"

Bear in mind that "turning left" or "turning right" does not move me anywhere - I have car that rotates on the spot ;)

Example

[['-','o','-','-','-'],
 ['-',' ',' ',' ','-'],
 ['-',' ','-',' ','-'],       This should return ["drive forward", "turn left", "drive forward", "turn right",
 ['-',' ','-',' ','-'],       "drive forward", "drive forward", "drive forward", "drive forward"]
 ['-',' ',' ',' ','-'],
 ['-','-','h','-','-']]
 

Sidenotes

I have made extensive efforts to make sure this kumite is original. If this is not the case, and you cannot personally retire it, please drop a comment with a link to that kumite, and I would be happy to rectify my mistake.

Also, I am aware this is setup much like a kata - but unfortunately with a kata you need a working solution, which I can't make! Maybe when this is functional, it can be converted into a Kata. ;)

def directions(map):
    return ["drive forward"]