Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Dirs = []Dir{
{"U", 0, -1},
{"D", 0, 1},
{"L", -1, 0},
{"R", 1, 0},
}
Dirs defines the direction updates for each cardinal point;
Functions ¶
func Run ¶
func Run(key string)
Example ¶
Run("pvhmgsws")
Output: Breadth First Shortest: (10) DRRDRLDURD Depth First Shortest: (10) DRRDRLDURD Longest: (618) DRRDRLDURLLRURLDDULDULDURUUDRLRLRDULLRDUURDULDUDDURLRLLRLDRUULRLRLRDRULLRDUDDDUULURDRRLDDLLUDRURLRUURLDDUDLURDUULRDUDURDDLRLLUDURRLUDRULDRUDDLLLRLRUDRLRRUULRLLDURDLLRLRDUDLURURLDRURDLUDRDLUULDRDDLRUULRDUULRDLDLDRLUUURRRLDDULDLUURLRLRLDRDRLULURDDRUDURUDULLRLRDRUDDLRLLDLRURLDRLURDUUDLUDDLRUULRRULDLURRRLDRLUDLDLRLRLRDUUDDLRLUURDDRUDLURRLRULRDLLLRUURRDLDDULUURDLRLDDURUDURLDULUDLDUDUUDRUDRUDULRDDLLRURRLRDLLDULRURLDRURLUDULRLDRULDDLRDRURUDLRUULRDDLRLUDRLUDDUULRDUDLDUUDRULDRUDURLULRDDRULDLLRUDDUUDDURLULDURRDRLDULUDLRLDURULRRDRLLLDUUDURRDDLRULDUUDUURDDLRDUDUULDUDDUURLRURDLULDRDDUDUUDLUDLRUDDUULDRRLUUDDRRULDDURUDULURDDD
func RunBreadthFirst ¶
RunBreadthFirst runs a breadth first search and reports the results.
key is the maze key specified in the problem.
func RunDepthFirst ¶
RunDepthFirst runs a depth first search and reports the results.//
key is the maze key specified in the problem.
Types ¶
type Dir ¶
Dir defines the direction updates for a cardinal point;
func GetOpenDirs ¶
GetOpenDirs gets the open directions for path, based on the algorithm in the problem statement.
type Maze ¶
Maze defines the structure of the maze. Since all the internal doors are computed based on the path, the internals of the maze need not be stored.
func (*Maze) BreadthFirstSearch ¶
BreadthFirstSearch runs a breadth first search.
paths is the list of paths (plus key) at the search front. Initially, this contains only the key specified in the problem.
func (*Maze) DepthFirstSearch ¶
DepthFirstSearch runs a depth first search.
key is the maze key specified in the problem.
If findAll is true, all valid paths are returned. If findAll is false, only the first valid path is returned.
func (*Maze) DepthFirstSearchExt ¶
func (m *Maze) DepthFirstSearchExt( pathCurrent string, x int, y int, exhaustive bool, pathAcc *[]string, ) bool
DepthFirstSearchExt runs a depth first search.
pathCurrent is the path to this point, including the key specified in the problem.
x and y are the current position. (Cheaper to pass than to re-compute from pathCurrent.)
If exhaustive is true, all valid paths are returned. If exhaustive is false, only the first valid path is returned.
pathAcc accumulates a list of valid paths.