Project Euler Lab - Problem 649

#649 - Low-Prime Chessboard Nim

● AdvancedOfficial difficulty: 32%CountingTier C - reduced scale in browser; full scale in notebookNot viewed
↖ Euler Lab
Alice and Bob are taking turns playing a game consisting of \(c\) different coins on a chessboard of size \(n\) by \(n\).

The game may start with any arrangement of \(c\) coins in squares on the board. It is possible at any time for more than one coin to occupy the same square on the board at the same time. The coins are distinguishable, so swapping two coins gives a different arrangement if (and only if) they are on different squares.

On a given turn, the player must choose a coin and move it either left or up \(2\), \(3\), \(5\), or \(7\) spaces in a single direction. The only restriction is that the coin cannot move off the edge of the board.

The game ends when a player is unable to make a valid move, thereby granting the other player the victory.

Assuming that Alice goes first and that both players are playing optimally, let \(M(n, c)\) be the number of possible starting arrangements for which Alice can ensure her victory, given a board of size \(n\) by \(n\) with \(c\) distinct coins.

For example, \(M(3, 1) = 4\), \(M(3, 2) = 40\), and \(M(9, 3) = 450304\).

What are the last \(9\) digits of \(M(10\,000\,019, 100)\)?

This problem is taken from Project Euler, Problem 649.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=649. Published Saturday, 29th December 2018, 01:00 pm. Solved by 522 members at time of mirroring.

Why this is useful

Algorithmic Development. Graph/state-space search transfers to routing, dependency resolution, and execution-path optimisation (Phases 16, 17).

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 C - reduced scale in browser; full scale in notebook
Browser runs a reduced, clearly-labelled educational scale; the original scale is provided in a local notebook.

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.