Signpost Signpost
Moderate
RU English

This mission is an adaptation of the "Signpost" game (from Simon Tatham's Portable Puzzle Collection). If you are lost or just want to play, the game is available here.

You're on a rectangular grid. You must find your way to go through the entire grid, following the directions indicated. Some boxes are already given like the start and the end of the path, you have to respect them.

The numbers say the location in the path, starting at 1. For example, a box with the number 9 indicates that this box is the ninth on the path.

Empty boxes are represented by zeros. Possible directions: north 'N', northwest 'NW', west 'W', southwest 'SW', south 'S', southeast 'SE', east 'E', northeast 'NE' and nothing '' (for the end of the path).

Then, you have to return the completed grid representing the path.

5x5 example image 5x5 example image

[[1, 0, 0, 0,  0],  (('SE', 'E' , 'SW', 'S' , 'S' ),       [[ 1, 13,  3, 14, 21],
 [0, 0, 9, 0, 18],   ('E' , 'W' , 'S' , 'NE', 'SW'),        [ 8,  7,  9, 20, 18],
 [0, 0, 0, 0,  0],   ('S' , 'N' , 'N' , 'N' , 'S' ),  ===\  [ 4,  6,  2, 19, 22],
 [0, 0, 0, 0,  0],   ('NE', 'N' , 'NE', 'SE', 'W' ),  ===/  [ 5, 12, 17, 24, 23],
 [0, 0, 0, 0, 25]]   ('NE', 'NE', 'W' , 'W' , ''  ))      ...

A list of lists of integers, and a tuple of tuples of strings.

A list/tuple of lists/tuples of integers.

signpost([[1, 0, 0],
          [0, 0, 0],
          [0, 0, 9]],
         (('S' , 'E' , 'S' ),
          ('S' , 'S' , 'NW'),
          ('NE', 'NE', ''  ))) == [[1, 7, 8],
                                   [2, 4, 6],
                                   [3, 5, 9]]
signpost([[1, 0, 0, 0,  0],
          [0, 0, 9, 0, 18],
          [0, 0, 0, 0,  0],
          [0, 0, 0, 0,  0],
          [0, 0, 0, 0, 25]],
         (('SE', 'E' , 'SW', 'S' , 'S' ),
          ('E' , 'W' , 'S' , 'NE', 'SW'),
          ('S' , 'N' , 'N' , 'N' , 'S' ),
          ('NE', 'N' , 'NE', 'SE', 'W' ),
          ('NE', 'NE', 'W' , 'W' , ''  ))) == [[ 1, 13,  3, 14, 21],
                                               [ 8,  7,  9, 20, 18],
                                               [ 4,  6,  2, 19, 22],
                                               [ 5, 12, 17, 24, 23],
                                               [11, 16, 10, 15, 25]]

You should be an authorized user in order to see the full description and start solving this mission.