Done day 4
[advent-of-code-20.git] / README.html
1 <!DOCTYPE html>
2 <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
3 <head>
4 <meta charset="utf-8" />
5 <meta name="generator" content="pandoc" />
6 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
7 <title>Advent of Code 2020</title>
8 <style type="text/css">
9 code{white-space: pre-wrap;}
10 span.smallcaps{font-variant: small-caps;}
11 span.underline{text-decoration: underline;}
12 div.column{display: inline-block; vertical-align: top; width: 50%;}
13 </style>
14 <link rel="stylesheet" href="modest.css" />
15 <!--[if lt IE 9]>
16 <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
17 <![endif]-->
18 </head>
19 <body>
20 <header>
21 <h1 class="title">Advent of Code 2020</h1>
22 </header>
23 <p>Code to solve the <a href="http://adventofcode.com/2020/">Advent of Code</a> puzzles. This year, I’m using the puzzles to develop my skills in <a href="https://wiki.haskell.org/Haskell">Haskell</a>. I’m writing up a <a href="https://work.njae.me.uk/tag/advent-of-code/">commentary on these puzzles and my solutions</a> on my blog.</p>
24 <p><a href="http://learnyouahaskell.com/chapters">Learn you a Haskell</a>, <a href="https://www.haskell.org/tutorial/index.html">Introduction to Haskell 98</a>, and <a href="https://hackage.haskell.org/">Hackage</a> are good resources.</p>
25 <p>The <a href="https://docs.haskellstack.org/en/stable/README/">Stack documentation</a> and <a href="http://howistart.org/posts/haskell/1/">How I Start: Haskell</a> are good sources of using the tools.</p>
26 <h1 id="toolchain">Toolchain</h1>
27 <p>I’m using the basic Haskell Platform installation, together with <code>stack</code> to manage the packages and dependencies (install with</p>
28 <pre><code>$ sudo aptitude install haskell-platform haskell-stack</code></pre>
29 <p>), then updgrade with</p>
30 <pre><code> stack upgrade --binary-only</code></pre>
31 <p>as the version in the Ubuntu repos is too old to work with current Haskell Stack package sets.</p>
32 <h2 id="creating-the-repository-and-project">Creating the repository and project</h2>
33 <p>Create the repository as normal: create the project in Gitolite, clone it, and insert the <code>.gitignore</code> and <code>README.md</code> files.</p>
34 <p>There’s one package per day, with the code for each package in sub-directories of the root directory.</p>
35 <p>Create the basic <code>stack</code> project. This will create a new directory. Note that this new directory name can’t have a hyphen-delimited word that’s just digits, so the project will have to be <code>advent-of-code</code></p>
36 <pre><code>stack new advent-of-code --bare simple</code></pre>
37 <p>Modify the <code>stack.yaml</code> file as needed, such as adding the <code>ghc-options</code> stanza.</p>
38 <h2 id="creating-subsequent-days">Creating subsequent days</h2>
39 <p>Each day lives in a separate directory, with its own <code>package.yaml</code> file and code in the <code>src</code> directory. (I based this configuration from <a href="https://github.com/mstksg/advent-of-code-2018">mstksg’s setup</a>.)</p>
40 <p>Compile with</p>
41 <pre><code>stack build</code></pre>
42 <p>or</p>
43 <pre><code>stack build advent01</code></pre>
44 <p>Run with</p>
45 <pre><code>stack exec advent01</code></pre>
46 <p>If you want to pass in additional RTS parameters, do it like this:</p>
47 <pre><code>stack exec -- advent01 +RTS -K0 -RTS</code></pre>
48 <p>Run interactively with</p>
49 <pre><code>stack ghci advent01</code></pre>
50 <p>or</p>
51 <pre><code>stack ghci advent01:exe:advent01</code></pre>
52 <p>if the first form is ambiguous.</p>
53 <p>To profile, use</p>
54 <pre><code>stack build --executable-profiling --library-profiling --ghc-options=&quot;-fprof-auto -rtsopts&quot; advent01</code></pre>
55 <p>then run with</p>
56 <pre><code>stack exec --profile -- advent01 +RTS -p -hy</code></pre>
57 <p>Generate the profile graph with</p>
58 <pre><code>stack exec hp2ps advent01.hp</code></pre>
59 <h1 id="packages">Packages</h1>
60 <p>Stack is using the <a href="https://www.stackage.org/lts-14.16">14.16-lts resolver</a> for packages, so make sure you read the <a href="https://www.stackage.org/lts-14.16/docs">correct documentation for the packages included in it</a>.</p>
61 <h1 id="readme">Readme</h1>
62 <p>Build this readme file wth</p>
63 <pre><code>pandoc -s README.md &gt; README.html</code></pre>
64 <p>(Using the <a href="https://github.com/markdowncss/modest">Modest style</a>.)</p>
65 </body>
66 </html>