Path Counting, also known as Block Walking, is a common problem in combinatorics that involves finding the number of unique paths from one corner of a grid to another, typically under certain restrictions. The most common scenario is finding the number of ways to move from the top-left corner to the bottom-right corner of a grid, moving only down or to the right at each step.
Here is a classic problem.
Imagine a grid of grid where is the number of rows and is the number of columns. You start at the top-left corner and want to reach the bottom-right corner. At each step, you can only move either right or down. How many unique paths are there?
The key to solving this problem lies in understanding that each path is a sequence of right and down moves. For a grid of size you must take exactly down moves and right moves to reach the destination, no matter the path taken.
The problem, therefore, reduces to determining in how many ways you can arrange these down moves and right moves. This is a permutation problem with a twist: since the moves of the same type are indistinguishable (all right moves are the same, and all down moves are the same), we use combinations instead of permutations.
The number of unique paths is given by the combination formula:
Here's another example to understand the formula
For a grid, we have down moves and right moves t make. Applying this formula gives us:
We calculate all the ways you can interleave the down adn right moves. By selecting which of the total steps will be down (or right), you automatically determine the sequence of moves.
When there are obstacles blocking a path, you simply pretend that it's the same grid with no obstacles and then subtract the number of paths that pass through that obstacle.
Here's a practice problem.
Given this grid, count the number of paths from the top left corner to the bottom right corner given that you can only go down or right.