← Complete problem index

PROJECT EULER · #0490

Jumping Frog

Statement only · UnsolvedOriginal problem ↗

There are n stones in a pond, numbered 1 to n. Consecutive stones are spaced one unit apart.

A frog sits on stone 1. He wishes to visit each stone exactly once, stopping on stone n. However, he can only jump from one stone to another if they are at most 3 units apart. In other words, from stone i, he can reach a stone j if 1jn and j is in the set {i3,i2,i1,i+1,i+2,i+3}.

Let f(n) be the number of ways he can do this. For example, f(6)=14, as shown below:
123456
123546
124356
124536
125346
125436
132456
132546
134256
135246
142356
142536
143256
145236

Other examples are f(10)=254 and f(40)=1439682432976.

Let S(L)=f(n)3 for 1nL.
Examples:
S(10)=18230635
S(20)=104207881192114219
S(1000)mod109=225031475
S(1000000)mod109=363486179

Find S(1014)mod109.

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.