76 lines
2.0 KiB
Plaintext
76 lines
2.0 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"# Problem 15:\n",
|
||
" \n",
|
||
"### [Euler Project #15](https://projecteuler.net/problem=15)\n",
|
||
" \n",
|
||
"### Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.\n",
|
||
"\n",
|
||
"### How many such routes are there through a 20×20 grid?\n",
|
||
"\n",
|
||
"---"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### Let's try to map the example cases, by assigning a binary value to RIGHT and DOWN moves.\n",
|
||
"\n",
|
||
" 0 = R <br>\n",
|
||
" 1 = D\n",
|
||
"\n",
|
||
" 0 0 1 1 <br>\n",
|
||
" 0 1 0 1 <br>\n",
|
||
" 0 1 1 0 <br>\n",
|
||
" 1 0 0 1 <br>\n",
|
||
" 1 0 1 0 <br>\n",
|
||
" 1 1 0 0 <br>\n",
|
||
"\n",
|
||
"### A couple things that shake out of this,\n",
|
||
"1. The total length of a sequence of moves is the equal to Length + Width of the grid.<br>\n",
|
||
" 1. So, for a 20x20, each sequence will be 40 moves in length.\n",
|
||
" 1. That could 2**40 possible combinations, most of which will not be valid.\n",
|
||
"2. Each unique sequence of moves has a twin which is a mirror across the diagonal.\n",
|
||
"3. Each valid sequence has an equal number of RIGHT and DOWN moves.\n",
|
||
"\n",
|
||
"### I'm sure there is some combinatorial mathematics that describes how to do this analytically. That will require some research, so I'll save this problem for another day.\n",
|
||
"\n",
|
||
"---"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": []
|
||
}
|
||
],
|
||
"metadata": {
|
||
"kernelspec": {
|
||
"display_name": "Python 3",
|
||
"language": "python",
|
||
"name": "python3"
|
||
},
|
||
"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.8.5"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 4
|
||
}
|