Project Euler Lab - Problem 314

#314 - The Mouse on the Moon

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

The moon has been opened up, and land can be obtained for free, but there is a catch. You have to build a wall around the land that you stake out, and building a wall on the moon is expensive. Every country has been allotted a \(\pu{500 m}\) by \(\pu{500 m}\) square area, but they will possess only that area which they wall in. \(251001\) posts have been placed in a rectangular grid with \(1\) meter spacing. The wall must be a closed series of straight lines, each line running from post to post.

The bigger countries of course have built a \(\pu{2000 m}\) wall enclosing the entire \(\pu{250 000 m^2}\) area. The Duchy of Grand Fenwick, has a tighter budget, and has asked you (their Royal Programmer) to compute what shape would get best maximum enclosed-area/wall-length ratio.

You have done some preliminary calculations on a sheet of paper. For a \(2000\) meter wall enclosing the \(\pu{250 000 m^2}\) area the enclosed-area/wall-length ratio is \(125\).
Although not allowed , but to get an idea if this is anything better: if you place a circle inside the square area touching the four sides the area will be equal to \(\pi \times \pu{250^2 m^2}\) and the perimeter will be \(\pi \times \pu{500 m}\), so the enclosed-area/wall-length ratio will also be \(125\).

However, if you cut off from the square four triangles with sides \(\pu{75 m}\), \(\pu{75 m}\) and \(75\pu{\sqrt 2 m}\) the total area becomes \(\pu{238750 m^2}\) and the perimeter becomes \(1400+300\pu{\sqrt 2 m}\). So this gives an enclosed-area/wall-length ratio of \(130.87\), which is significantly better.

0314_landgrab.gif

Find the maximum enclosed-area/wall-length ratio.
Give your answer rounded to \(8\) places behind the decimal point in the form abc.defghijk.

This problem is taken from Project Euler, Problem 314.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=314. Published Sunday, 12th December 2010, 07:00 am. Solved by 620 members at time of mirroring.

Why this is useful

Numerical Computing. Precision, conditioning, and numerical iteration transfer directly to pricing engines and model calibration (Phases 5, 13, 15).

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.