Project Euler Lab - Problem 519

#519 - Tricoloured Coin Fountains

● AdvancedOfficial difficulty: 60%CountingTier C - reduced scale in browser; full scale in notebookNot viewed
↖ Euler Lab

An arrangement of coins in one or more rows with the bottom row being a block without gaps and every coin in a higher row touching exactly two coins in the row below is called a fountain of coins. Let \(f(n)\) be the number of possible fountains with \(n\) coins. For \(4\) coins there are three possible arrangements:

0519_coin_fountain.png

Therefore \(f(4) = 3\) while \(f(10) = 78\).

Let \(T(n)\) be the number of all possible colourings with three colours for all \(f(n)\) different fountains with \(n\) coins, given the condition that no two touching coins have the same colour. Below you see the possible colourings for one of the three valid fountains for \(4\) coins:

0519_tricolored_coin_fountain.png

You are given that \(T(4) = 48\) and \(T(10) = 17760\).

Find the last \(9\) digits of \(T(20000)\).

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

Why this is useful

Mathematical Foundation. Exact counting underlies discrete pricing lattices, scenario enumeration, and combinatorial probability (Phase 7).

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.