add problem 99
This commit is contained in:
parent
10c5b9bc7d
commit
95a5cfdeeb
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e71fcbbb",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# [Largest Exponential](https://projecteuler.net/problem=99)\n",
|
||||
"\n",
|
||||
"Instead of trying to compare the powers $x^y$ directly, compare their logarithms $y\\log{x}$."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "0180569c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(\"txt/0099_base_exp.txt\") as f:\n",
|
||||
" pairs = tuple(tuple(int(x) for x in line.split(\",\")) for line in f)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "a0c22c9e",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(709, (895447, 504922))"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"logpows = {(x, y): y * log(x) for (x, y) in pairs}\n",
|
||||
"max(enumerate(logpows, start=1), key=lambda x: logpows[x[1]])"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "SageMath 9.5",
|
||||
"language": "sage",
|
||||
"name": "sagemath"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue