Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown committed Dec 30, 2023
0 parents commit 45bece5
Show file tree
Hide file tree
Showing 288 changed files with 52,308 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 36fe7955bb9fdcf07b113265aa58eb3b
tags: 645f666f9bcd5a90fca523b33c5a78b7
Empty file added .nojekyll
Empty file.
191 changes: 191 additions & 0 deletions _modules/day01/day1a.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>day01.day1a &mdash; adventofcode2023 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />


<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->

<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=5929fcd5"></script>
<script src="../../_static/doctools.js?v=888ff710"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>

<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >



<a href="../../index.html" class="icon icon-home">
adventofcode2023
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../autodoc.html">Automatic documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ci.html">Continuous Integration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">adventofcode2023</a></li>
</ul>

</div>
</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">adventofcode2023</a>
</nav>

<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li>
<li class="breadcrumb-item active">day01.day1a</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>Source code for day01.day1a</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;day1a solution.&quot;&quot;&quot;</span>


<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Optional</span>

<span class="n">INPUT</span> <span class="o">=</span> <span class="s2">&quot;day01/input.txt&quot;</span>
<span class="n">INPUT_SMALL</span> <span class="o">=</span> <span class="s2">&quot;day01/input-small.txt&quot;</span>


<div class="viewcode-block" id="get_first_last">
<a class="viewcode-back" href="../../day01.html#day01.day1a.get_first_last">[docs]</a>
<span class="k">def</span> <span class="nf">get_first_last</span><span class="p">(</span><span class="n">line</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Returns first and last numeric character of a string.</span>

<span class="sd"> It can be the same character.</span>

<span class="sd"> Args:</span>
<span class="sd"> line (str): string to parse</span>

<span class="sd"> Raises:</span>
<span class="sd"> ValueError: When there are no numbers in the string</span>

<span class="sd"> Returns:</span>
<span class="sd"> tuple[str, str]: first char, last char</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">first</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">last</span><span class="p">:</span> <span class="nb">str</span>
<span class="k">for</span> <span class="n">char</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
<span class="k">if</span> <span class="n">char</span><span class="o">.</span><span class="n">isnumeric</span><span class="p">():</span>
<span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">first</span> <span class="o">=</span> <span class="n">char</span>
<span class="n">last</span> <span class="o">=</span> <span class="n">char</span>

<span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;first should be set by now&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="p">(</span><span class="n">first</span><span class="p">,</span> <span class="n">last</span><span class="p">)</span></div>



<div class="viewcode-block" id="get_input">
<a class="viewcode-back" href="../../day01.html#day01.day1a.get_input">[docs]</a>
<span class="k">def</span> <span class="nf">get_input</span><span class="p">(</span><span class="n">input_file</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Grabs list of lines to parse from input file.</span>

<span class="sd"> Args:</span>
<span class="sd"> input_file (str): input file&#39;s name</span>

<span class="sd"> Returns:</span>
<span class="sd"> list[str]: list of lines to parse</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">input_file</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">&quot;utf8&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span>
<span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">file</span><span class="p">)</span></div>



<div class="viewcode-block" id="part1">
<a class="viewcode-back" href="../../day01.html#day01.day1a.part1">[docs]</a>
<span class="k">def</span> <span class="nf">part1</span><span class="p">(</span><span class="n">lines</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="nb">str</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="nb">int</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Runs day1/part1 of adventofcode2023.</span>

<span class="sd"> Args:</span>
<span class="sd"> lines (list[str]): list of lines to parse</span>

<span class="sd"> Returns:</span>
<span class="sd"> int: sum of results for each line.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">total</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span><span class="p">:</span>
<span class="n">first</span><span class="p">,</span> <span class="n">last</span> <span class="o">=</span> <span class="n">get_first_last</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
<span class="n">data</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">first</span> <span class="o">+</span> <span class="n">last</span><span class="p">)</span>
<span class="n">total</span> <span class="o">+=</span> <span class="n">data</span>
<span class="k">return</span> <span class="n">total</span></div>



<div class="viewcode-block" id="main">
<a class="viewcode-back" href="../../day01.html#day01.day1a.main">[docs]</a>
<span class="k">def</span> <span class="nf">main</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Grabs input then processes it.&quot;&quot;&quot;</span>
<span class="n">lines</span> <span class="o">=</span> <span class="n">get_input</span><span class="p">(</span><span class="n">INPUT</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">part1</span><span class="p">(</span><span class="n">lines</span><span class="p">))</span></div>



<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span>
<span class="n">main</span><span class="p">()</span>
</pre></div>

</div>
</div>
<footer>

<hr/>

<div role="contentinfo">
<p>&#169; Copyright 2023, Alex Ong.</p>
</div>

Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.


</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>

</body>
</html>
Loading

0 comments on commit 45bece5

Please sign in to comment.