The distance between point $A$ and $B$ is $7$ units. The initial position is $A$. How many ways to reach point $B$ in $21$ steps. Each step can be either one unit forward or one unit backward.
I tried in the following way :
$a = $ No of
forward steps used.
$b = $ No of
backward steps used.
We need $a+b = 21 \;\;\;\; $ and $\;\;\;a - b = 7$.
Solving these $\;\; b = 7$. Now, I thought, how many ways these $b$ backward steps can be used?
I could not use
generating function to select $b$ steps out of $7$ available locations because permutation is also possible.
I also tried $2$ state dynamic programming and wrote a program.
But I want a more formal way of counting.