A man is standing at the bottom left corner of an 1 1 × 1 1 grid of city streets. He wants to get to the top right corner of the grid while only travelling up and to the right. The man does not want to turn too often along the route, so he will only take a path such that any time he walks up or right, he walks at least two consecutive blocks in that direction. How many different paths can he take to the top right corner if he starts by walking to the right ?
Details and assumptions
There are 11 city streets and hence 10 city blocks.
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.
am I the only one who did exactly this but misunderstood the problem as 11x11 blocks -_- (I used all 3 tries before the clarification came out)
Log in to reply
If you did that, I think the answer should have been too large for Brilliant's range....
Log in to reply
Ya, I think so.
I did calculated by 11X11 but answer was in thousands.
I mean it's not like the wording is ambiguous. Clarification or not, you should know that 11 streets means 10 blocks.
Log in to reply
Right, it's not ambiguous per se, but I think many people just skimmed the problem and thought the man had to go 11 blocks. (Plus some may not be very fluent in English.)
We start with the following result: For positive integers n and m , the number of solutions to a 1 + a 2 + ⋯ + a n = m , where each a i is a positive integer that is at least 2, is ( n − 1 m − n − 1 ) .
Proof : Let b i = a i − 1 , so each b i is a positive integer. Then a i = b i + 1 . Substituting and simplifying, we get b 1 + b 2 + ⋯ + b n = m − n . By stars-and-bars, the number of solutions to this equation is ( n − 1 m − n − 1 ) . It is easy to see that every solution in the b i corresponds to a solution in the a i . ■
We can represent each path as a string of Rs and Us, where each R corresponds to a step to the right, and each U corresponds to a step up. This string will contain 10 Rs and 10 Us. Furthermore, by the specifications in the problem, each "block" of Rs and Us will contain at least two letters. (For example, the string RRRUURRRRRUUUU consists of the four blocks RRR, UU, RRRRR, and UUUU.)
Let r be the number of blocks of Rs, and let u be the number of blocks of Us. Since the first step is to the right, and the blocks must alternate between Rs and Us, either r = u or r = u + 1 .
Consider the case r = u . Each block of Rs must contain at least two Rs, and there are 10 Rs total, so 1 ≤ r ≤ 5 . By the result we proved at the start, there are ( r − 1 9 − r ) ways to distribute 10 Rs among r blocks, and since u = r , we have the same number for the Us.
Next, consider the case r = u + 1 . In this case, 2 ≤ r ≤ 5 . Again, there are ( r − 1 9 − r ) ways to distribute 10 Rs among r blocks, and since u = r − 1 , there are ( u − 1 9 − u ) = ( r − 2 1 0 − r ) ways to distribute the Us.
Therefore, the total number of possible paths is r = 1 ∑ 5 ( r − 1 9 − r ) ( r − 1 9 − r ) + r = 2 ∑ 5 ( r − 1 9 − r ) ( r − 2 1 0 − r ) = 6 4 8 .
There is also a solution using recursion. Let f ( r , u ) denote the number of strings containing r Rs and u Us, so that each block contains at least two letters. Then f satisfies the recursion f ( r , u ) = f ( r − 1 , u ) + f ( r , u − 1 ) − f ( r − 1 , u − 1 ) + f ( r − 2 , u − 2 ) for all r ≥ 2 and u ≥ 2 , except when r = u = 2 . (I will leave the proof of this as an exercise.)
Here are the first few values of f ( r , u ) :
r \ u 0 1 2 3 4 5 0 1 0 1 1 1 1 1 0 0 0 0 0 0 2 1 0 2 2 3 4 3 1 0 2 2 3 4 4 1 0 3 3 6 9 5 1 0 4 4 9 1 4
Continuing the table, we find f ( 1 0 , 1 0 ) = 1 2 9 6 , so the answer is 1 2 9 6 / 2 = 6 4 8 . (We divide by 2, because in the problem, the first step is to the right.)
Different approach; good use of various mathematical theorems and ideas, instead of usual counting method. Nice one.
I also found a recursion. f ( m , n , d ) is the number of ways to travel a m ∗ n grid going direction d ( u : up, r : right) (except for base cases): f ( m , n , u ) = f ( m − 2 , n , r ) + f ( m − 1 , n , u ) f ( m , n , r ) = f ( m , n − 2 , u ) + f ( m , n − 1 , r ) I made a 10x10 grid of doubles of numbers (and got the answer after catching an arithmetic mistake in the middle of the grid the first time :) ).
Log in to reply
I got the same recursion. Here's my approach (probably not the simplest one):
Any path that travels a
m
×
n
grid with it's last step being
↑
must intersect the right border at some point, say
(
m
,
k
)
, where
0
≤
k
≤
n
−
2
. The previous step must be
→
. From our definition, there are
f
(
m
,
k
,
r
)
ways to reach this. Since
k
can be any integer between
0
and
n
−
2
, we obtain
f
(
m
,
n
,
u
)
=
k
=
0
∑
n
−
2
f
(
m
,
k
,
r
)
=
k
=
0
∑
n
−
3
f
(
m
,
k
,
r
)
+
f
(
m
,
n
−
2
,
r
)
=
f
(
m
,
n
−
1
,
u
)
+
f
(
m
,
n
−
2
,
r
)
The other recursion can be obtained similarly.
I guess I messed somewhere in the arithmetic calculations, and used up all three tries. :(
Simple exhaustion method:
The man can take the paths
2 − 2 − 2 − 2 − 2 ,
2 − 2 − 2 − 4 , 2 − 2 − 3 − 3 ,
2 − 2 − 6 , 2 − 3 − 5 , 2 − 4 − 4 , 3 − 3 − 4 ,
2 − 8 , 3 − 7 , 4 − 6 , 5 − 5 ,
1 0 .
With order into account, this makes 1 , 1 0 , 1 5 , 7 , 1 paths of length 5 , 4 , 3 , 2 , 1 , respectively. He starts with the right; if he takes a n step path in the right direction then he must take either a n or n − 1 step path in the up direction. Thus, the sum is 1 ( 1 0 + 1 ) + 1 0 ( 1 0 + 1 5 ) + 1 5 ( 1 5 + 7 ) + 7 ( 7 + 1 ) + 1 ( 1 ) = 6 4 8 .
So first we note that any path must either have the same number of horizontal and vertical segments, or one more horizontal segment. Each solution will be a pairing of a two partitions of 10 into parts of at least 2. Now let's count the partitions of 10 into parts of at least 2, grouping by number of parts:
1 part: 1
2 parts:7
3 parts:15
4 parts:10
5 parts:1
Now we square each of these and add them to get 1 + 7 ∗ 7 + 1 5 ∗ 1 5 + 1 0 ∗ 1 0 + 1 = 3 7 6 Now we add each times the one after for the case where the number of segments are not equal: 1 ∗ 7 + 7 ∗ 1 5 + 1 5 ∗ 1 0 + 1 0 ∗ 1 = 2 7 2 . 272+376=648
Each way is made of alternating R (right) and U (up) 's starting with R. For each such way number of R's would decide which partition of 10 we need to use. Same applies for U's.
Example: If we have RURUR as path pattern, then we will use 3 part for R's and 2 part for U's.
Ways to distribute 10 into smaller integers such that each part is greater than or equal to 2 is:
Into 1 part : - 1 0
Into 2 part : - 2 + 8 , 3 + 7 , 4 + 6 , 5 + 5
Into 3 part : - 2 + 2 + 6 , 2 + 3 + 5 , 2 + 4 + 4 , 3 + 3 + 4
Into 4 part : - 2 + 2 + 2 + 4 , 2 + 2 + 3 + 3
Into 5 part : - 2 + 2 + 2 + 2 + 2
Number of ways partitions can be used can be calculated as the number of different permutations of that particular partitions
Example: 2 Part can have 2 permutation each of ( 2 + 8 , 3 + 7 , 4 + 6 ) and 1 permutation of 5 + 5 . Thus total of 7 permutations.
We get,
1 Part = 1
2 Part = 7
3 Part = 1 5
4 Part = 1 0
5 Part = 1
To get the number of ways any particular pattern can be traveled we simply need to multiply R's part ways to U's part ways, since they are mutually independent.
Example: RURUR can be traveled in ( 3 P a r t ) × ( 2 P a r t ) = 1 5 × 7 = 1 0 5 w a y s .
Now counting the number of ways the man can travel along particular path pattern:
RU = 1 × 1 = 1
RUR = 7 × 1 = 7
RURU = 7 × 7 = 4 9
RURUR = 1 5 × 7 = 1 0 5
RURURU = 1 5 × 1 5 = 2 2 5
RURURUR = 1 0 × 1 5 = 1 5 0
RURURURU = 1 0 × 1 0 = 1 0 0
RURURURUR = 1 × 1 0 = 1 0
RURURURURU = 1 × 1 = 1
Adding up we get 6 4 8
Look at the possible partitions of 1 0 using numbers only greater than or equal to 2 :
1 0 , 8 + 2 , 7 + 3 , 6 + 4 , 5 + 5 , 6 + 2 + 2 , 5 + 3 + 2 , 4 + 4 + 2 , 4 + 3 + 3 , 4 + 2 + 2 + 2 , 3 + 3 + 2 + 2 , 2 + 2 + 2 + 2 + 2
But since we also have to consider permutations of these partitions, there is 1 partition with length 1 , 7 with length 2 , 1 5 with length 3 , 1 0 with length 4 , and 1 with length 5 . A possible path can either have two with the same length or one with length 1 less than the other one, so the answer is
1 + 7 ( 7 + 1 ) + 1 5 ( 1 5 + 7 ) + 1 0 ( 1 0 + 1 5 ) + 1 ( 1 + 1 0 ) = 6 4 8
Problem Loading...
Note Loading...
Set Loading...
The man has to walk 1 0 block-lengths up and 1 0 block-lengths to the right; he has to take a path (right, up, right, up, etc.), where each section is at least 2 blocks long, So, we list out the partitions of 1 0 (ways to represent 1 0 as the sum of positive integers) with each part at least 2 , divided up by the number of parts:
1 partition with 1 part: 1 1 x1
7 partitions with 2 parts: 2 + 8 3 + 7 4 + 6 5 + 5 x2 , x2 , x2 , x1
1 5 partitions with 3 parts: 2 + 2 + 6 2 + 3 + 5 2 + 4 + 4 3 + 3 + 4 x3 , x6 , x3 , x3
1 0 partitions with 4 parts: 2 + 2 + 2 + 4 2 + 2 + 3 + 3 x4 , x6
1 partition with 5 parts: 2 + 2 + 2 + 2 + 2 x1
(The multipliers after each partition are to adjust for ordering.)
Since the man starts by going right, the path must have either same number of right-parts as up-parts (for example, right-up-right-up), or 1 more right-part than up-parts (for example, right-up-right-up-right). Also, once the number of right-parts and up-parts is determined, any 2 partitions with those numbers of parts will work. Using these facts, we list out all possible cases:
Thus, in total, there are 1 + 7 + 4 9 + 1 0 5 + 2 2 5 + 1 5 0 + 1 0 0 + 1 0 + 1 = 6 4 8 possible paths the man could take. ■