Project Euler Lab - Problem 573

#573 - Unfair Race

● ResearchOfficial difficulty: 97%RandomnessTier C - reduced scale in browser; full scale in notebookNot viewed
↖ Euler Lab

\(n\) runners in very different training states want to compete in a race. Each one of them is given a different starting number \(k\) \((1\leq k \leq n)\) according to the runner's (constant) individual racing speed being \(v_k=\frac{k}{n}\).
In order to give the slower runners a chance to win the race, \(n\) different starting positions are chosen randomly (with uniform distribution) and independently from each other within the racing track of length \(1\). After this, the starting position nearest to the goal is assigned to runner \(1\), the next nearest starting position to runner \(2\) and so on, until finally the starting position furthest away from the goal is assigned to runner \(n\). The winner of the race is the runner who reaches the goal first.

Interestingly, the expected running time for the winner is \(\frac{1}{2}\), independently of the number of runners. Moreover, while it can be shown that all runners will have the same expected running time of \(\frac{n}{n+1}\), the race is still unfair, since the winning chances may differ significantly for different starting numbers:

Let \(P_{n,k}\) be the probability for runner \(k\) to win a race with \(n\) runners and \(E_n = \sum_{k=1}^n k P_{n,k}\) be the expected starting number of the winner in that race. It can be shown that, for example, \(P_{3,1}=\frac{4}{9}\), \(P_{3,2}=\frac{2}{9}\), \(P_{3,3}=\frac{1}{3}\) and \(E_3=\frac{17}{9}\) for a race with \(3\) runners.
You are given that \(E_4=2.21875\), \(E_5=2.5104\) and \(E_{10}=3.66021568\).

Find \(E_{1000000}\) rounded to \(4\) digits after the decimal point.

This problem is taken from Project Euler, Problem 573.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=573. Published Sunday, 9th October 2016, 07:00 am. Solved by 252 members at time of mirroring.

Why this is useful

Probability Statistics. Expectation and state-based probability reasoning underpin pricing, risk, and statistical inference (Phases 7, 11, 13).

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.