Project Euler Lab - Problem 344

#344 - Silver Dollar Game

● ResearchOfficial difficulty: 95%CountingTier D - conceptual / notebook executionNot viewed
↖ Euler Lab

One variant of N.G. de Bruijn's silver dollar game can be described as follows:

On a strip of squares a number of coins are placed, at most one coin per square. Only one coin, called the silver dollar, has any value. Two players take turns making moves. At each turn a player must make either a regular or a special move.

A regular move consists of selecting one coin and moving it one or more squares to the left. The coin cannot move out of the strip or jump on or over another coin.

Alternatively, the player can choose to make the special move of pocketing the leftmost coin rather than making a regular move. If no regular moves are possible, the player is forced to pocket the leftmost coin.

The winner is the player who pockets the silver dollar.

0344_silverdollar.gif

A winning configuration is an arrangement of coins on the strip where the first player can force a win no matter what the second player does.

Let \(W(n,c)\) be the number of winning configurations for a strip of \(n\) squares, \(c\) worthless coins and one silver dollar.

You are given that \(W(10,2) = 324\) and \(W(100,10) = 1514704946113500\).

Find \(W(1\,000\,000, 100)\) modulo the semiprime \(1000\,036\,000\,099\) (\(= 1\,000\,003 \cdot 1\,000\,033\)).

This problem is taken from Project Euler, Problem 344.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=344. Published Saturday, 25th June 2011, 07:00 pm. Solved by 407 members at time of mirroring.

Why this is useful

Algorithmic Development. Optimal substructure and state-space reasoning are exactly how American-option pricing and optimal execution are solved (Phases 13, 16).

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 D - conceptual / notebook execution
Too heavy for browser Pyodide at original scale: the browser is used for planning, small cases and reasoning; full scale runs 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.