move notebooks to subdir
This commit is contained in:
60
notebooks/problem0004.ipynb
Normal file
60
notebooks/problem0004.ipynb
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9c7a281d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# [Largest Palindrome Product](https://projecteuler.net/problem=4)\n",
|
||||
"\n",
|
||||
"Our search space is only $\\binom{900}{2} = 404550$ 3-digit pairs - a lot to check by hand but peanuts to a modern computer (we're using notation for [combinations](https://en.wikipedia.org/wiki/Combination) if you're unfamiliar)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "e5fd66f6",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"906609"
|
||||
]
|
||||
},
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from itertools import combinations\n",
|
||||
"\n",
|
||||
"is_palindrome = lambda x: str(x) == str(x)[::-1]\n",
|
||||
"three_digit_pairs = combinations(range(100, 1000), 2)\n",
|
||||
"max(x*y for (x,y) in three_digit_pairs if is_palindrome(x*y))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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
|
||||
}
|
||||
Reference in New Issue
Block a user