Project Euler Lab - Problem 737

#737 - Coin Loops

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

A game is played with many identical, round coins on a flat table.

Consider a line perpendicular to the table.
The first coin is placed on the table touching the line.
Then, one by one, the coins are placed horizontally on top of the previous coin and touching the line.
The complete stack of coins must be balanced after every placement.

The diagram below [not to scale] shows a possible placement of 8 coins where point \(P\) represents the line.

It is found that a minimum of \(31\) coins are needed to form a coin loop around the line, i.e. if in the projection of the coins on the table the centre of the \(n\)th coin is rotated \(\theta_n\), about the line, from the centre of the \((n-1)\)th coin then the sum of \(\displaystyle\sum_{k=2}^n \theta_k\) is first larger than \(360^\circ\) when \(n=31\). In general, to loop \(k\) times, \(n\) is the smallest number for which the sum is greater than \(360^\circ k\).

Also, \(154\) coins are needed to loop two times around the line, and \(6947\) coins to loop ten times.

Calculate the number of coins needed to loop \(2020\) times around the line.

This problem is taken from Project Euler, Problem 737.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=737. Published Sunday, 6th December 2020, 04:00 am. Solved by 455 members at time of mirroring.

Why this is useful

General Problem Solving. Builds computational thinking, decomposition, and debugging discipline - transferable, without a specific financial application.

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

Prerequisites

Lessons that prepare you:
19.7 Dynamic Programming: Memoization and Tabulation

Recommended stepping-stone problems: #313 · #692 · #961

Concepts: game-theory

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.