Scenario
An agent moves on a 2D integer grid from origin (0,0) to destination (m,n). Each step must be either one unit Right (+1,0) or one unit Up (0,+1). A hazardous obstacle is located at coordinate (x,y) where 0<x<m and 0<y<n.
Your Task
- State the total number of unconstrained paths from (0,0) to (m,n).
- By applying the multiplication principle of combinatorics, calculate the number of paths that pass directly through the obstacle (x,y).
- Derive the exact formula for valid paths avoiding the obstacle using the subtraction rule (Inclusion-Exclusion).
- Compute the valid paths for m=5,n=5 with an obstacle at (2,3).
Constraints
- Only Right and Up steps allowed.
- 0<x<m,0<y<n.
Examples
For m=2,n=2 avoiding (1,1): Total paths (24)=6. Paths through (1,1)=(12)(12)=4. Valid paths = 6−4=2.