Project Euler Lab - Problem 662

#662 - Fibonacci Paths

● AppliedOfficial difficulty: 30%PointsTier B - browser, with the efficient algorithmNot viewed
↖ Euler Lab

Alice walks on a lattice grid. She can step from one lattice point \(A (a,b)\) to another \(B (a+x,b+y)\) providing distance \(AB = \sqrt{x^2+y^2}\) is a Fibonacci number \(\{1,2,3,5,8,13,\ldots\}\) and \(x\ge 0,\) \(y\ge 0\).

In the lattice grid below Alice can step from the blue point to any of the red points.

0662_fibonacciwalks.png

Let \(F(W,H)\) be the number of paths Alice can take from \((0,0)\) to \((W,H)\).
You are given \(F(3,4) = 278\) and \(F(10,10) = 215846462\).

Find \(F(10\,000,10\,000) \bmod 1\,000\,000\,007\).

This problem is taken from Project Euler, Problem 662.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=662. Published Sunday, 24th March 2019, 01:00 am. Solved by 994 members at time of mirroring.

Why this is useful

Numerical Computing. Matrix methods and linear-recurrence acceleration are the machinery behind covariance work, PCA, and lattice/transition models (Phases 4, 5, 8).

We classify relevance honestly - not every Euler problem is a trading application.

Learning mode

Pick how much scaffolding you want. Your choice is remembered per problem.

Scratchpad

Mathematical notes, formulas, pseudocode, hypotheses, complexity notes. Saved automatically with your progress.

Python workbench

Tier B - browser, with the efficient algorithm
Runs in the browser only with the intended efficient algorithm; a naive loop will hit the timeout.

Real Python (Pyodide) in a sandboxed Web Worker - no network, no filesystem, no DOM access. Ctrl/Cmd+Enter runs. Escape leaves the editor. Stop terminates the worker.

Python runtime not loaded (it boots on first run - a one-time local load).

Check your answer

Answers are checked against a salted hash held in a separate file - not printed in this page. This prevents accidental spoilers; it is not cryptographic protection (see the build notes).

Progressive hints

Confidence

Low confidence schedules this problem for spaced review, even if you solved it.

Reference solution

Spoiler
The complete original explanation (interpretation, naive approach, insight, proof, complexity, Python implementation, tests, common mistakes, alternatives) is hidden and lazy-loaded. Reveal it only after a meaningful attempt - the struggle is where the learning happens.