Adding problem 15 as a JN.
This commit is contained in:
73
problems/015_problem/015_problem.ipynb
Normal file
73
problems/015_problem/015_problem.ipynb
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
{
|
||||||
|
"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.\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, but I'd rather practice programming a loop, than researching an elegant solution. \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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user