Solved 61, 62, 63.

This commit is contained in:
2019-01-06 00:50:37 -05:00
parent 3020b89719
commit 550a1479f0
7 changed files with 570 additions and 12 deletions

View File

@@ -20,6 +20,51 @@
"Find the smallest cube for which exactly five permutations of its digits are cube."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"cubes = [n * n * n for n in range(1, 5000)]\n",
"cubes_set = set(cubes)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[127035954683, 352045367981, 373559126408, 569310543872, 589323567104]\n",
"127035954683\n"
]
}
],
"source": [
"solutions = {}\n",
"\n",
"for n in range(1, 10000):\n",
" cube = n * n * n\n",
" try:\n",
" key = \"\".join(sorted(str(cube)))\n",
" solutions[key].append(cube)\n",
" if len(solutions[key]) > 4:\n",
" print(solutions[key])\n",
" s = solutions[key][0]\n",
" break\n",
" except KeyError:\n",
" solutions[key] = [cube]\n",
"\n",
"print(s)\n",
"assert(s == 127035954683)"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -31,7 +76,7 @@
}
],
"metadata": {
"completion_date": "",
"completion_date": "Sun, 6 Jan 2019, 05:47",
"kernelspec": {
"display_name": "Python 3",
"language": "python3.6",
@@ -49,7 +94,9 @@
"pygments_lexer": "ipython3",
"version": "3.6.5"
},
"tags": []
"tags": [
"cubes"
]
},
"nbformat": 4,
"nbformat_minor": 2