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>EulerProblem026</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,17 +11762,15 @@ 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-26">Euler Problem 26<a class="anchor-link" href="#Euler-Problem-26">&#182;</a></h1><p>A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:</p>
<h1 id="Euler-Problem-26">Euler Problem 26<a class="anchor-link" href="#Euler-Problem-26"></a></h1><p><a href="/euler">Back to overview.</a></p><p>A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:</p>
<pre><code>1/2 = 0.5
1/3 = 0.(3)
1/4 = 0.25
@@ -11788,7 +11782,6 @@ div#notebook {
1/10 = 0.1</code></pre>
<p>Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle.</p>
<p>Find the value of d &lt; 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part.</p>
</div>
</div>
</div>
@@ -11798,15 +11791,14 @@ div#notebook {
<div class="text_cell_render border-box-sizing rendered_html">
<p>The trick here is to identify a cycle. The easiest way I see to do this is to memorize the remainders. If we have a remainder that we occurred previously there is a cycle.</p>
<p>Let's consider 1/3. The initial remainder is 10. For ten divided by three the new remainder is again ten (or one times ten). So we have a one-cycle of 3.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[1]:</div>
<div class="prompt input_prompt">In [1]:</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_cycle_count</span><span class="p">(</span><span class="n">nominator</span><span class="p">,</span> <span class="n">denominator</span><span class="p">):</span>
<span class="kn">from</span> <span class="nn">itertools</span> <span class="k">import</span> <span class="n">count</span>
<span class="k">assert</span><span class="p">(</span><span class="n">nominator</span> <span class="o">==</span> <span class="mi">1</span><span class="p">)</span>
@@ -11829,60 +11821,44 @@ div#notebook {
<span class="k">assert</span><span class="p">(</span><span class="n">get_cycle_count</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">get_cycle_count</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">6</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
<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">
<p>This is a simple divison algorithm. The only special thing is the remainder and that we remember when it occurs the first time. If a remainder occurrs for the second time we substract the position and thus have the lenght of the cycle. With this solution we should be efficient enough to brute force.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[2]:</div>
<div class="prompt input_prompt">In [2]:</div>
<div class="inner_cell">
<div class="input_area">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">s</span> <span class="o">=</span> <span class="nb">max</span><span class="p">([(</span><span class="n">get_cycle_count</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">i</span><span class="p">),</span> <span class="n">i</span><span class="p">)</span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1000</span><span class="p">)])</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">s</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="k">assert</span><span class="p">(</span><span class="n">s</span> <span class="o">==</span> <span class="mi">983</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">s</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>983
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>