<jupyter_start><jupyter_text>Largest exponential Comparing two numbers written in index form like 211 and 37 is not difficult, as any calculator would confirm that 211 = 2048 7 = 2187.However, confirming that 632382518061 > 519432525806 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. ---  Idea Assume two pairs, $ (a_1, b_1) $, $ (a_2, b_2) $, $ m_1 = a_1^{b_1} $, $ m_2 = a_2^{b_2} $, then we can transfer the comparison of $ m_1 $ with $ m_2 $ to comparison of $ \frac{m_1}{m_2} $ with 1.And it is easy to transfer to comparions of $ \log\frac{m_1}{m_2}$ with 0, which means $ \log{m_1} - \log{m_2} $ with 0, which means $ b_1 * \log{a_1} - b2 * \log{a_2} $ with 0.So the greatest numerical value is the one with greatest value of $ b * \log{a} $ ---<jupyter_code>import sys, os; sys.path.append(os.path.abspath('..'))
from timer import timethis
from urllib.request import urlopen
from math import log
with urlopen('https://projecteuler.net/project/resources/p099_base_exp.txt') as f:
    resp = f.read().decode('utf-8')
pairs = [tuple(map(int, line.split(','))) for line in resp.splitlines()]
pairs[:5]
@timethis
def solve():
    return max(enumerate(pairs, 1), key=lambda enu: enu[1][1] * log(enu[1][0]))
solve()<jupyter_output>Run for 0.000 seconds
{'fraction_non_alphanumeric': 0.12436868686868686, 'fraction_numerical': 0.052398989898989896, 'mean_word_length': 4.446735395189004, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '414119', 'license': 'MIT', 'n_tokens_mistral': 576, 'n_tokens_neox': 529, 'n_words': 199, 'path': '76-100/p99.ipynb', 'repo_name': 'Sorosliu1029/Euler', 'size': '1584'}