How many { ( 1 , 1 ) , ( 1 , − 1 ) , ( 2 , 0 ) } -lattice paths are there from the point ( 0 , 0 ) to the line x = 8 ?
Details and assumptions
A lattice path is a path in the Cartesian plane between points with integer coordinates.
A step in a lattice path is a single move from one point with integer coordinates to another.
The size of the step from ( x 1 , y 1 ) to ( x 2 , y 2 ) is ( x 2 − x 1 , y 2 − y 1 ) .
For a set S = { ( x i , y i ) } i = 1 k , an S -lattice path is a lattice path where every step has size which is a member of S .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Same way, good solution. To get to any line x=m the number of way would be k = 0 ∑ 2 m ( k m − k ) ⋅ 2 m − 2 k .
To simplify the problem, we need to find the value of f ( 0 ) , in which f ( n ) denotes the number of different lattice paths available from a point in line x = n to the line x = 8 using the given steps.
We want to know how many lattice paths will stop exactly at the line x = 8 . Since all the steps have positive x-values, any point ( x i , y i ) with x i > 8 will never reach the line x = 8 again. i.e,
For ( n > 8 ) , f ( n ) = 0
Any point in line x = 8 is already located at the target x-coordinate. Therefore, there is only one possible lattice path for any point in the line x = 8 , which is an empty set. Therefore,
For ( n = 8 ) , f ( n ) = 1
Lastly, using only the three different steps, we can conclude that in any point ( x i , y i ) (in other words, a point located at line x = x i , you can either advance to a point located in line x = x i + 1 in two different ways, or to a point in line x = x i + 2 . Thus,
For ( n < 8 ) , f ( n ) = 2 × f ( n + 1 ) + f ( n + 2 )
Using the functions above, we can obtain the value of f ( 0 ) , namely 985.
Let a n be the number of ways to get to the line x = n . For n > 1 , the last step of the path could be any one of the three steps. Consider all paths that end with the step ( 1 , 1 ) . If we remove this step, we are left with paths to the line x = n − 1 . By definition, there are a n − 1 such paths. Similarly, there are a n − 1 paths to x = n that end with the step ( 1 , − 1 ) and a n − 2 paths that end with ( 2 , 0 ) . Thus, for n > 1 , we find the relation
a n = 2 a n − 1 + a n − 2 .
It is easy to check that a 1 = 2 and a 2 = 5 . By repeated use of the recurrence relation, we easily find a 8 = 9 8 5 .
Note that if such a path contains a given point ( x , y ) , there are only 3 possible immediate predecessors to that point: ( x − 1 , y − 1 ) , ( x − 1 , y + 1 ) , ( x − 2 , y ) . Let S ( x , y ) represent the number of paths from ( 0 , 0 ) to ( x , y ) . Then S ( x , y ) = S ( x − 1 , y − 1 ) + S ( x − 1 , y + 1 ) + S ( x − 2 , y ) . Now let P n represent the number of paths from ( 0 , 0 ) to x = n . Then P n = y = − ∞ ∑ ∞ S ( n , y ) = y = − ∞ ∑ ∞ S ( n − 1 , y − 1 ) + S ( n − 1 , y + 1 ) + S ( n − 2 , y ) = 2 y = − ∞ ∑ ∞ S ( n − 1 , y ) + y = − ∞ ∑ ∞ S ( n − 2 , y ) = 2 P n − 1 + P n − 2 , with the initial conditions P 0 = 1 and P 1 = 2 (which we enumerate by inspection). We may then directly compute P 2 = 5 , P 3 = 1 2 , P 4 = 2 9 , P 5 = 7 0 , P 6 = 1 6 9 , P 7 = 4 0 8 , and P 8 = 9 8 5 .
Note that P n are known as Pell numbers.
Since the path is strictly to the x-value of x=8, we don't even need to consider the y-value when creating a path. All we need to consider is that there are two distinct ways of moving to right 1 space and one distinct way of moving to the right 2 spaces.
Let A be the number of times we move 1 space to the right in a path and B be the number of times we move 2 spaces to the right in a path. As we can see, A + 2 B = 8 for a valid path.
There are 2 A ways to make lattice paths strictly out of 1-space steps because there are 2 ways of moving to the right 1 space (as previously stated). By the multiplication rule for A steps, we get 2 A .
There is only 1 way to make a path with just 2-space steps because there is only one 2-space point available to use. But, the number of distinct combinations of 2-space steps in a path is ( B A + B ) .
Thus, for each pair ( A , B ) , there are 2 A ( B A + B ) different paths. Since A = 8 − 2 B and 0 ≤ B ≤ 4 to ensure 0 ≤ A ≤ 8 , we can find the total number of paths to be B = 0 ∑ 4 2 8 − 2 B ( B 8 − B ) = 2 5 6 B = 0 ∑ 4 B ! ( 8 − 2 B ) ! 4 B ( 8 − B ) ! = 9 8 5 paths
To view this in a simpler way, consider this casework (1s symbolize 1-space steps and 2s symbolize 2-space steps):
11111111 - 2 8 ( 0 8 ) = 2 5 6
1111112 - 2 6 ( 1 7 ) = 4 4 8
111122 - 2 4 ( 2 6 ) = 2 4 0
11222 - 2 2 ( 3 5 ) = 4 0
2222 - 2 0 ( 4 4 ) = 1
Summing 2 5 6 + 4 4 8 + 2 4 0 + 4 0 + 1 = 9 8 5 .
Separate into paths with a given number of ( 2 , 0 ) steps.
If there are no ( 2 , 0 ) steps, then the path has length 8 and there are two choices for each step, so there are 2 8 such paths.
If there is one ( 2 , 0 ) step, then the path has length 7 . There are 2 6 choices for the non-horizontal part of the path, and then ( 1 7 ) places to put the horizontal step, so there are 2 6 ( 1 7 ) such paths.
If there are two ( 2 , 0 ) steps, then the path has length 6 . There are 2 4 choices for the non-horizontal part of the path, and then ( 2 6 ) choices for the placing of the two horizontal steps, so there are 2 4 ( 2 6 ) such paths.
Similar reasoning leads to 2 2 ( 3 5 ) and 2 0 ( 4 4 ) paths with 3 and 4 horizontal steps, respectively. So the sum is 2 8 + 2 6 ( 1 7 ) + 2 4 ( 2 6 ) + 2 2 ( 3 5 ) + 2 0 ( 4 4 ) = 9 8 5 .
The path could have:
There's 1 possibility for first case: (2,2) (2,2) (2,2) (2,2)
In the second case, we need to choose 3 of the 5 steps for the (2,2)'s then there are
2
2
possibilities for the (1,-1) and (-1,1).
(
3
5
)
∗
2
2
=
4
0
Third case. We need to choose 2 of the 6 steps, then 2 possibilities for every of the 4 remaining steps: ( 2 6 ) ∗ 2 4 = 2 4 0
Fourth case: 7 possibilities for the (2,2) and 2 possibilities for each of the 6 remaining. 7 ∗ 2 6 = 4 4 8
Last case: there are 8 steps to choose between (1,1) and (1,-1), i.e. 2 8 = 2 5 6
1+40+240+448+256 = 985
Let c i be the number of paths from some point in line x = i to the line x = 8 using the steps given in the problem statement. We get the recursion:
c i = 2 c i + 1 + c i + 2
with the initial conditions:
c 8 = 1 (there is exactly one path from a point on the line x = 8 to itself, the path with 0 steps.
c 7 = 2 (to go from a point on line x = 7 to line x = 8 we have to use one of the steps ( 1 , 1 ) or ( 1 , − 1 ) .
This gives us:
c 6 = 2 c 7 + c 8 = 5
c 5 = 2 c 6 + c 7 = 1 2
c 4 = 2 c 5 + c 6 = 2 9
c 3 = 2 c 4 + c 5 = 7 0
c 2 = 2 c 3 + c 4 = 1 6 9
c 1 = 2 c 2 + c 3 = 4 0 8
c 0 = 2 c 1 + c 2 = 9 8 5
From ( 0 , 0 ) we have to go 8 step toward the x axis. So we have 5 cases:
Case 1 : We have to use size ( 2 , 0 ) , 0 times . So, in this case we can go 2 8 = 2 5 6 ways.
Case 2 : We have to use size ( 2 , 0 ) , 1 times . So, in this case we can go 6 ! 2 6 × 7 ! = 4 4 8 ways.
Case 3 : We have to use size ( 2 , 0 ) , 2 times . So, in this case we can go 2 ! × 4 ! 2 4 × 6 ! = 2 4 0 ways.
Case 4 :We have to use size ( 2 , 0 ) , 3 times . So, in this case we can go 2 ! × 3 ! 2 2 × 5 ! = 4 0 ways.
Case 5 : We have to use size ( 2 , 0 ) , 4 times . So, in this case we can go 1 ways.
Now, we have total, 2 5 6 + 4 4 8 + 2 4 0 + 4 0 + 1 = 9 8 5
Notice that two steps have x-coordinate 1, while the third has x-coordinate 2. We seek to use a sequence of these three steps so that the x-coordinates of them all add to 8. We break this into cases based on the number of 2's.
Case 1: 4 (2, 0)'s Obviously there is 1 in this case.
Case 2: 3 (2, 0)'s There are 5 steps in this path. Two of them will be non-(2, 0)'s, so there are 2 2 ( 2 5 ) in this case.
Case 3: 2 (2, 0)'s 6 steps, 4 are non-(2, 0). This gives 2 4 ( 2 6 )
Case 4: 1 (2, 0) 7 steps, 6 are non-(2, 0). This gives 2 6 ( 1 7 )
Case 5: No (2, 0)'s There are 2 choices for each step, giving 2 8 .
Summing these all gives 1 + 4 0 + 2 4 0 + 4 4 8 + 2 5 6 = 9 8 5
Consider a step of size (i, j). If we take 0, 1, 2, n of these steps, we've travelled (0, 0), (i, j), (2i, 2j), (ni, nj). Based on this observation, we can express all possible distances travelled using this step alone as a generating function on x i y j .
For step (1, 1), we have x 0 y 0 + x 1 y 1 + x 2 y 2 + . . . = ∑ a = 0 ∞ x a y a
For step (1, -1), we have x 0 y 0 + x 1 y − 1 + x 2 y − 2 + . . . = ∑ b = 0 ∞ x b y − b
For step (2, 0), we have x 0 y 0 + x 2 y 0 + x 4 y 0 + . . . = ∑ c = 0 ∞ x 2 c
The steps are pairwise independent, so the product of the generating functions ∑ a , b , c ≥ 0 x a + b + 2 c y a − b will give us all possible combinations of steps to get from (0, 0) to any point (x, y). For x = 8, we want all non-negative solutions to a + b + 2 c = 8 . Each solution represents a path that takes a+b+c steps. These steps can be taken in any order, so this means we need to permute a, b, c objects of types 1, 2, 3 respectively.
c | Permutations |
0 | ( 0 , 8 , 0 8 ) + ( 1 , 7 , 0 8 ) + ( 2 , 6 , 0 8 ) + . . . + ( 8 , 0 , 0 8 ) = ( 0 8 ) + ( 1 8 ) + ( 2 8 ) + . . . + ( 8 8 ) = 256 |
1 | ( 0 , 6 , 1 7 ) + ( 1 , 5 , 1 7 ) + ( 2 , 4 , 1 7 ) + . . . + ( 6 , 0 , 1 7 ) = ( 1 7 ) ( ( 0 6 ) + ( 1 6 ) + ( 2 6 ) + . . . + ( 6 6 ) ) = 7*64 = 448 |
2 | ( 0 , 4 , 2 6 ) + ( 1 , 3 , 2 6 ) + ( 2 , 2 , 2 6 ) + ( 3 , 1 , 2 6 ) + ( 4 , 0 , 2 6 ) = ( 2 6 ) ( ( 0 4 ) + ( 1 4 ) + ( 2 4 ) + ( 3 4 ) + ( 4 4 ) ) = 15*16 = 240 |
3 | ( 0 , 2 , 3 5 ) + ( 1 , 1 , 3 5 ) + ( 0 , 2 , 3 5 ) = ( 3 5 ) ( ( 0 2 ) + ( 1 2 ) + ( 2 2 ) ) = 20*2 = 40 |
4 | ( 0 , 0 , 4 4 ) = 1 |
Number of paths = 256 + 448 + 240 + 40 + 1 = 985
@Matt O That's a great approach using generating functions! I've converted your comment into a solution. Could you add more details to it? Thanks!
Log in to reply
Thanks Calvin! This means a lot from you. For the record, I like the many approaches used here especially simplicity of the the linear recurrence which is more of a dynamic programming used in programming.
I'm wondering if there is a way to simplify my approach. As I was writing up my solution, I realized the dichotomy my generating function approach and and this problem that I needed to reconcile (combinations versus permutations). Is there a way to simplify my approach or was I doomed for the computations I made above?
The number of paths to x = 1 is clearly 2 (select one of the first two moves), and the number of paths to x = 2 is clearly 5 (either one of the first two moves followed by another (4) or just the third (1)).
Then, if N n denotes the number to x = n, we have N n = 2 N n − 1 + N n − 2 , considering each of the three possibilities for the last move.
Running this recurrence generates 2,5,12,29,70,169,408,985.
Let P n be the number of paths from the point ( 0 , 0 ) to the line x = n . Consider the last step of such a path. If it is a ( 2 , 0 ) step, then the rest of the path is a path in P n − 2 . If the last step is ( 1 , 1 ) or ( 1 , − 1 ) then the rest of the path is a path in P n − 1 . Thus, the number of paths of length n is P n = P n − 2 + 2 P n − 1 . We know that P 0 = 1 and P 1 = 2 . We recursively calculate the following values:
n P n 0 1 1 2 2 5 3 1 2 4 2 9 5 7 0 6 1 6 9 7 4 0 8 8 9 8 5
Thus, there are 9 8 5 paths to the line x = 8 .
Can I possibly contribute a new solution? Yes, I can!
From the point ( 0 , 0 ) to the line x = n ≥ 0 there are P ( n ) = 4 ( 2 + 2 ) ( 1 + 2 ) n + ( 2 − 2 ) ( 1 − 2 ) n of these paths. In fact, since the second term is very small, P ( n ) = [ ( 4 1 ( 2 + 2 ) ⋅ ( 1 + 2 ) n ] , where [ ⋅ ] stands for rounding off to the nearest integer.
With n = 8 , P ( 8 ) ≈ [ 0 . 8 5 3 5 5 ⋅ 2 . 4 1 4 2 8 ] = 9 8 5 .
(Admittedly, I first derived the recursion relation that many other solutions here show. But now we have a direct equation that works quickly for all values of n . For instance, for n = 2 0 we have 3 8 6 1 3 9 6 5 paths.)
Here is how the equation was derived: the general solution of a recurrence of the form a n = 2 a n − 1 + a n − 2 is the sum of two exponential sequences, a n = c + p + n + c − p − n . The bases p ± must satisfy p ± 2 = 2 p ± + 1 ∴ p ± = 1 ± 2 . To find the coefficients c ± , we use a − 1 = 0 and a 0 = 1 to find c + + c − = 1 , ( − 1 + 2 ) c + + ( − 1 − 2 ) c − = 0 . (Note that 1 / ( 1 ± 2 ) = − 1 ± 2 .) Substituting the first equation in the second, we see that − 1 + ( c + − c − ) 2 ∴ c + − c − = 2 1 2 . Adding and subtracting the equations for c + ± c − , we finally get c ± = 2 1 ± 4 1 2 = 4 1 ( 2 ± 2 ) .
Let A n be the number of paths to \x=n
Problem Loading...
Note Loading...
Set Loading...
We shall make cases based on no. of (2,0) steps.
Generalization : If no. of (2,0) steps is x and no. of (1,-1) and (1,1) steps is y.
Then no. of lattice paths is 2 y ∗ ( x x + y )
Proof: total steps = x+y
No. of ways to place (2,0) step is ( x x + y ) .
Remaining y places to be filled with either (1,1) or (1,-1) step.
Each remaining place can be filled in 2 different ways.
So remaining y places can be filled in 2 y ways.
So total ways = 2 y ∗ ( x x + y )
Now We shall make cases based on no. of (2,0) steps.
1.No. of (2,0) steps=0 , no. of ways= 2 8 ∗ ( 0 8 )
2.No. of (2,0) steps=1 , no. of ways= 2 6 ∗ ( 1 7 )
3.No. of (2,0) steps=2 , no. of ways= 2 4 ∗ ( 2 6 )
4.No. of (2,0) steps=3 , no. of ways= 2 2 ∗ ( 3 5 )
5.No. of (2,0) steps=4 , no. of ways= 2 0 ∗ ( 4 4 )
Ans = 985