Plow Every Cell
grid is a list of strings, one per row: S is the garage where a snowplow starts, E is the depot where it must finish, . is a snowy cell and # is a wall. The plow moves up, down, left or right one cell at a time, never enters a wall, and may not enter any cell a second time. A valid route starts at S, ends at E, and passes through every snowy cell exactly once. Return the number of valid routes. There is exactly one S and exactly one E.
Example 1
Only the two snake patterns cover all nine cells: row by row, or column by column.
Example 2
The plow must clear the top-right and bottom-right cells before it can enter the depot: S, right, down, left.
Constraints
1 <= rows, cols <= 10rows * cols <= 20grid[r]has only the charactersS,E,.and#, with oneSand oneEin the whole grid
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Grids problems
- Push the Crate to the MarkHard
- Roll Until It StopsHard
- Slide the Tiles Into PlaceHard
- Wall Off the OutbreakHard
- Water Held by the LandHard
- Column TotalsBeginner
- Count Negatives in a Sorted GridBeginner
- Cross TotalBeginner