Euler has design of a homepage and there is a link back to the overview for each solution.

This commit is contained in:
2018-06-14 20:11:26 -04:00
parent 894160d1a0
commit c34ebd6181
48 changed files with 1134 additions and 2394 deletions

View File

@@ -1,9 +1,9 @@
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<head><meta charset="utf-8"/>
<title>EulerProblem015</title><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<style type="text/css">
/*!
*
@@ -11714,8 +11714,6 @@ ul.typeahead-list > li > a {
.ansi-bold { font-weight: bold; }
</style>
<style type="text/css">
/* Overrides of notebook CSS for static HTML export */
body {
@@ -11741,15 +11739,13 @@ div#notebook {
}
}
</style>
<!-- Custom stylesheet, it must be in the same directory as the html file -->
<link rel="stylesheet" href="custom.css">
<link href="custom.css" rel="stylesheet"/>
<!-- Loading mathjax macro -->
<!-- Load mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- MathJax configuration -->
<script type="text/x-mathjax-config">
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- MathJax configuration -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
@@ -11766,19 +11762,17 @@ div#notebook {
}
});
</script>
<!-- End of mathjax configuration --></head>
<!-- End of mathjax configuration --></head>
<body>
<div tabindex="-1" id="notebook" class="border-box-sizing">
<div class="container" id="notebook-container">
<div class="border-box-sizing" id="notebook" tabindex="-1">
<div class="container" id="notebook-container">
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Euler-Problem-15">Euler Problem 15<a class="anchor-link" href="#Euler-Problem-15">&#182;</a></h1><p>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.</p>
<p><img src="https://projecteuler.net/project/images/p015.gif" alt="problem picture"></p>
<h1 id="Euler-Problem-15">Euler Problem 15<a class="anchor-link" href="#Euler-Problem-15"></a></h1><p><a href="/euler">Back to overview.</a></p><p>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.</p>
<p><img alt="problem picture" src="https://projecteuler.net/project/images/p015.gif"/></p>
<p>How many such routes are there through a 20×20 grid?</p>
</div>
</div>
</div>
@@ -11788,21 +11782,19 @@ div#notebook {
<div class="text_cell_render border-box-sizing rendered_html">
<p>We should be able to get this with some thinking. Every move for a $nxn$ grid has to contain n downward and n rightward moves. So in total there are 2n moves. Now we only have to get all permutations available with 2n moves. Normally, we would calculate the factorial, but this only works if all symbols are different. In this case we always only have two symbols for the 2n moves.
For each solution there exist a certain number of ways we can create this solution. Let's assume we have two right arrows called (1, 2) and two down arrows called (3, 4). We now have the following options to generate the solution in the upper left corner.</p>
<pre><code>1 2 3 4
1 2 4 3
2 1 3 4
2 1 4 2</code></pre>
<p>So this means if we calculate the number of ways using the factorial $(2\times2)! = 4! = 24$, four of the solutions are equal which gives us $\frac{24}{4} = 6$. The way to calculate the four should be $2! \times 2! = 4$, so our formula is $\frac{(2\times n)!}{n! \times n!}$. So let's try that.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[4]:</div>
<div class="prompt input_prompt">In [4]:</div>
<div class="inner_cell">
<div class="input_area">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">def</span> <span class="nf">get_number_of_routes</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
<span class="kn">from</span> <span class="nn">math</span> <span class="k">import</span> <span class="n">factorial</span>
<span class="k">return</span> <span class="n">factorial</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">n</span><span class="p">)</span> <span class="o">//</span> <span class="p">(</span><span class="n">factorial</span><span class="p">(</span><span class="n">n</span><span class="p">)</span> <span class="o">*</span> <span class="n">factorial</span><span class="p">(</span><span class="n">n</span><span class="p">))</span>
@@ -11811,29 +11803,20 @@ For each solution there exist a certain number of ways we can create this soluti
<span class="k">assert</span><span class="p">(</span><span class="n">get_number_of_routes</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span> <span class="o">==</span> <span class="mi">137846528820</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">get_number_of_routes</span><span class="p">(</span><span class="mi">20</span><span class="p">))</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>137846528820
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
@@ -11843,15 +11826,10 @@ For each solution there exist a certain number of ways we can create this soluti
<p>So the final formula is</p>
<p>$n_{routes} = \frac{(d \times n)!}{(n!)^d}$</p>
<p>where d is the number of dimensions and n is the size of the grid.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>