Draft

Through the Maze

Description:

Can you get through mazes?

var maze= [ [ '_', '_', '_', 'W', '_', '_' ],
            [ 'W', 'W', '_', 'W', '_', '_' ],
            [ 'W', 'W', '_', '_', 'W', '_' ],
            [ '_', 'W', '_', '_', '_', 'W' ],
            [ '_', '_', '_', '_', '_', 'x' ],
            [ 'W', 'W', 'W', 'W', 'W', 'W' ] ]

Maze rules:

  • Start from the top left corner, and get to "x" in vertical or horizontal steps of 1.
  • You are allowed to move left, right, or down. For simplicity, the maze format will not require you to move upwards, although it is not prohibited by any test.
  • Only "_" and "x" cells are valid. Do not hit walls ("W" cells);
  • Do not go out of the maze's bounds;
  • Stop after finding x.

Your solution shall be an object containing the "path" and "values" keys.

  • "path" array keeps track of all the cells in the maze (see "toXpath" array in sample test case);
  • "values" array keeps track of all encountered cells contents. (see toXvalues array in sample test case);

Assumptions:

  • A Maze will have NxN cells, where N is an integer between 5 and 100;
  • Random (>=1) number of walls ("W"-cells-only rows) at the bottom of the maze.
  • "x" is located in the row just above the series of wall-rows.
  • The test cases do not require a specific path to be taken.
Arrays
Strings

More By Author:

Check out these other kata created by franzmoro88

Stats:

CreatedDec 3, 2015
Warriors Trained89
Total Skips0
Total Code Submissions352
Total Times Completed24
JavaScript Completions24
Total Stars7
% of votes with a positive feedback rating75% of 10
Total "Very Satisfied" Votes7
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes2
Total Rank Assessments12
Average Assessed Rank
4 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • franzmoro88 Avatar
  • smile67 Avatar
Ad