Project Euler Lab - Problem 262

#262 - Mountain Range

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

The following equation represents the continuous topography of a mountainous region, giving the elevationheight above sea level \(h\) at any point \((x, y)\): \[h = \left(5000 - \frac{x^2 + y^2 + xy}{200} + \frac{25(x + y)}2\right) \cdot e^{-\left|\frac{x^2 + y^2}{1000000} - \frac{3(x + y)}{2000} + \frac 7 {10}\right|}.\]

A mosquito intends to fly from \(A(200,200)\) to \(B(1400,1400)\), without leaving the area given by \(0 \le x, y \le 1600\).

Because of the intervening mountains, it first rises straight up to a point \(A^\prime\), having elevation \(f\). Then, while remaining at the same elevation \(f\), it flies around any obstacles until it arrives at a point \(B^\prime\) directly above \(B\).

First, determine \(f_{\mathrm{min}}\) which is the minimum constant elevation allowing such a trip from \(A\) to \(B\), while remaining in the specified area.
Then, find the length of the shortest path between \(A^\prime\) and \(B^\prime\), while flying at that constant elevation \(f_{\mathrm{min}}\).

Give that length as your answer, rounded to three decimal places.

Note: For convenience, the elevation function shown above is repeated below, in a form suitable for most programming languages:
h=( 5000-0.005*(x*x+y*y+x*y)+12.5*(x+y) ) * exp( -abs(0.000001*(x*x+y*y)-0.0015*(x+y)+0.7) )

This problem is taken from Project Euler, Problem 262.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=262. Published Friday, 30th October 2009, 09:00 pm. Solved by 874 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.