Write a function (using as few bytes as possible) that takes a bi-dimensional array of any number of columns and rows in which:
0
represents empty block,1
represents snake block.
The function must return the number of possible paths the snake traveled.
Example 1:
Input:
[
[1,1,1,1,1],
[0,0,0,0,1],
[0,0,0,0,1],
]
Output: 2
In the example above, the function will return 2
because the answer is either one of:
Example 2:
Input:
[
[1,1,1,1],
[0,0,1,1],
[0,0,1,1],
]
Output: 6
In this example the function will return 6
because the answer is either one of:
Note:
When assessing the input, you can assume that:
- The arrays representing columns will always have the same sizes (so the arrays are rectangular);
- There exists at least 1 valid path;
- The snake cannot walk through the edges (as can happen in some versions of snake);
- The snake will always have at least 2 blocks;
- The snake cannot move diagonally;
- The paths are directed. (so, two paths ending at different positions but otherwise looking exactly the same are not the same path, it’ll add up to the total)
[[0,0,1,1],[0,0,1,1],[0,0,1,1]]
. Most answers give 16, but one gives 15. \$\endgroup\$