Solution 1
This is easily solved by recursion/dynamic programming. To simplify the problem somewhat, let us imagine the seven vertices on a line E↔P4↔P5↔S↔P1↔P2↔P3↔E. We can count the number of left/right (L/R) paths of length ≤11 that start at S and end at either P4 or P3.
We can visualize the paths using the common grid counting method by starting at the origin (0,0), so that a right (R) move corresponds to moving 1 in the positive x direction, and a left (L) move corresponds to moving 1 in the positive y direction. Because we don't want to move more than 2 units left or more than 3 units right, our path must not cross the lines y=x+2 or y=x−3. Letting p(x,y) be the number of such paths from (0,0) to (x,y) under these constraints, we have the following base cases:
p(x,0)={10x≤3x>3p(0,y)={10y≤2y>2
and recursive step p(x,y)=p(x−1,y)+p(x,y−1) for x,y≥1.
The filled in grid will look something like this, where the lower-left 1 corresponds to the origin:
00001110003321009963102828191041898961331440108471400155470001550000
The bolded numbers on the top diagonal represent the number of paths from S to P4 in 2, 4, 6, 8, 10 moves, and the numbers on the bottom diagonal represent the number of paths from S to P3 in 3, 5, 7, 9, 11 moves. We don't care about the blank entries or entries above the line x+y=11. The total number of ways is 1+3+9+28+89+1+4+14+47+155=351.
(Solution by scrabbler94)
Solution 2
Let En denotes the number of sequences with length n that ends at E. Define similarly for the other vertices. We seek for a recursive formula for En.
En=P3n−1+P4n−1=P2n−2+P5n−2=P1n−3+P3n−3+Sn−3+P4n−3=(P3n−3+P4n−3)+Sn−3+P1n−3=En−2+Sn−3+P1n−3=En−2+P1n−4+P5n−4+Sn−4+P2n−4=En−2+(Sn−4+P1n−4)+P5n−4+P2n−4=En−2+(En−1−En−3)+Sn−5+P4n−5+P1n−5+P3n−5=En−2+(En−1−En−3)+(Sn−5+P1n−5)+(P4n−5+P3n−5)=En−2+(En−1−En−3)+(En−2−En−4)+En−4=En−1+2En−2−En−3
Computing a few terms we have E0=0, E1=0, E2=0, E3=1, and E4=1.
Using the formula yields E5=3, E6=4, E7=9, E8=14, E9=28, E10=47, E11=89, and E12=155.
Finally adding yields ∑k=012Ek=351.
~ Nafer
Get solution faster in Sol 2
In the 5th to last line, we have P5n−4+P2n−4=En−2 by shifting the index in line 2.
Solution 3
For vertices S,P1,P2,P5, the number of ways to get there after n jumps is the sum of the number of ways to get to the adjacent vertices after n−1 jumps. For vertices P3, and P4, the number of ways to get there after n jumps is he number of ways to get to P2 and P5 after n−1 jumps.
Jump#123456789101112AOPSPROTECTED52TOKEN020601906101970638AOPSPROTECTED53TOKEN103010033010803520AOPSPROTECTED54TOKEN010401404701550507AOPSPROTECTED55TOKEN0010401404701550AOPSPROTECTED56TOKEN001134914284789155AOPSPROTECTED57TOKEN0103090280890286AOPSPROTECTED58TOKEN1030902808902860
0+0+1+1+3+4+9+14+28+47+89+155=351.
Video Solution
https://www.youtube.com/watch?v=uWNExJc3hok