Project Euler Lab - Problem 923

#923 - Young's Game B

● ResearchOfficial difficulty: 95%Two-player gamesTier C - reduced scale in browser; full scale in notebookNot viewed
↖ Euler Lab

A Young diagram is a finite collection of (equally-sized) squares in a grid-like arrangement of rows and columns, such that

  • the left-most squares of all rows are aligned vertically;
  • the top squares of all columns are aligned horizontally;
  • the rows are non-increasing in size as we move top to bottom;
  • the columns are non-increasing in size as we move left to right.

Two examples of Young diagrams are shown below.

0922_youngs_game_diagrams.png

Two players Right and Down play a game on several Young diagrams, all disconnected from each other. Initially, a token is placed in the top-left square of each diagram. Then they take alternating turns, starting with Right. On Right's turn, Right selects a token on one diagram and moves it one square to the right. On Down's turn, Down selects a token on one diagram and moves it one square downwards. A player unable to make a legal move on their turn loses the game.

For \(a,b,k\geq 1\) we define an \((a,b,k)\)-staircase to be the Young diagram where the bottom-right frontier consists of \(k\) steps of vertical height \(a\) and horizontal length \(b\). Shown below are four examples of staircases with \((a,b,k)\) respectively \((1,1,4),\) \((5,1,1),\) \((3,3,2),\) \((2,4,3)\).

0922_youngs_game_staircases.png

Additionally, define the weight of an \((a,b,k)\)-staircase to be \(a+b+k\).

Let \(S(m, w)\) be the number ways of choosing \(m\) staircases, each having weight not exceeding \(w\), upon which Right (moving first in the game) will win the game assuming optimal play. Different orderings of the same set of staircases are to be counted separately.

For example, \(S(2, 4)=7\) is illustrated below, with tokens as grey circles drawn in their initial positions.

0922_youngs_game_example.png

You are also given \(S(3, 9)=315319\).

Find \(S(8, 64)\) giving your answer modulo \(10^9+7\).

This problem is taken from Project Euler, Problem 923.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=923. Published Saturday, 21st December 2024, 04:00 pm. Solved by 121 members at time of mirroring.

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.