Automatic commit performed through alias...

This commit is contained in:
Shaun Setlock
2020-08-14 20:57:58 -04:00
parent 2ee9b4f63a
commit 288e646086
3 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
{
"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
}

View File

@@ -0,0 +1,35 @@
# Problem 15:
#
# [Euler Project #15](https://projecteuler.net/problem=15)
#
# 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.
#
# How many such routes are there through a 20×20 grid?
#
# ---
# Let's try to map the example cases, by assigning a binary value to RIGHT and DOWN moves.
# 0 = R
# 1 = D
#
# 0 0 1 1
# 0 1 0 1
# 0 1 1 0
# 1 0 0 1
# 1 0 1 0
# 1 1 0 0
# A couple things that shake out of this,
# 1. The total length of a sequence of moves is the equal to Length + Width of the grid.
# 2. Each unique sequence of moves has a twin which is a mirror across the diagonal.
# 3. Each valid sequence has an equal number of RIGHT and DOWN moves.
# 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.
length=20
width=20
move_sequence_length=length+width
count=0