From 7ccce9ea372e16598d7149c07628620d7dee2049 Mon Sep 17 00:00:00 2001 From: Shaun Setlock Date: Sun, 2 Aug 2020 22:00:06 -0400 Subject: [PATCH] Automatic commit performed through alias... --- problems/015_problem/015_problem.py | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 problems/015_problem/015_problem.py diff --git a/problems/015_problem/015_problem.py b/problems/015_problem/015_problem.py new file mode 100644 index 0000000..f994ddb --- /dev/null +++ b/problems/015_problem/015_problem.py @@ -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