Project Euler Lab - Problem 99

#99 - Largest Exponential

● FoundationOfficial difficulty: 6%WordsTier A - full browser executionNot viewed
↖ Euler Lab

Comparing two numbers written in index form like \(2^{11}\) and \(3^7\) is not difficult, as any calculator would confirm that \(2^{11} = 2048 \lt 3^7 = 2187\).

However, confirming that \(632382^{518061} \gt 519432^{525806}\) would be much more difficult, as both numbers contain over three million digits.

Using base_exp.txt (right click and 'Save Link/Target As...'), a 22K text file containing one thousand lines with a base/exponent pair on each line, determine which line number has the greatest numerical value.

NOTE: The first two lines in the file represent the numbers in the example given above.

This problem is taken from Project Euler, Problem 99.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=99. Published Friday, 1st July 2005, 06:00 pm. Solved by 34,344 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:
17.1 Python for Quants: NumPy, pandas, and Vectorization · 19.4 Exact Arithmetic: Big Integers, Rationals, and Floating-Point Traps

Concepts: string-processing

Likely techniques: big-integer

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 A - full browser execution
Runs at full original scale within the browser limits.

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.

This problem has a data file
The dataset 0099_base_exp.txt is bundled locally and pre-loaded into your Python environment as DATA (a string) and DATA_LINES (a list of lines). No download or network access is needed. Download the file.
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.