|
1 |
| -Haskell¹ solutions to [Advent of Code 2023](https://adventofcode.com/2023). |
| 1 | +Haskell and Swift¹ solutions to [Advent of Code 2023](https://adventofcode.com/2023). |
| 2 | + |
| 3 | +Each solution is in a self-contained file with zero dependencies that can be |
| 4 | +run directly by the stock Haskell and Swift compilers. For example: |
| 5 | + |
| 6 | + cat examples/18 | runghc 18.hs |
| 7 | + cat examples/18 | swift 18.swift |
| 8 | + |
| 9 | +More details about running, including some convenient `make` invocations, are |
| 10 | +described below. |
2 | 11 |
|
3 | 12 | <small>¹ The primary solutions are is Haskell. But for some problems, I've also
|
4 |
| -done variations using other means and languages. </small> |
| 13 | +done variations using other means and languages, mostly Swift.</small> |
5 | 14 |
|
6 | 15 | ## Running
|
7 | 16 |
|
8 |
| -Install [Haskell using GHCup](https://www.haskell.org/ghcup/). Then, to run the |
9 |
| -latest solution on the latest of its example inputs, use |
| 17 | +Install [Haskell using GHCup](https://www.haskell.org/ghcup/), or |
| 18 | +[Swift](https://swift.org), depending on which solutions you want to run. |
| 19 | + |
| 20 | +Then, to run the latest solution on the latest of its example inputs, use |
10 | 21 |
|
11 | 22 | make
|
12 | 23 |
|
13 | 24 | Other commands:
|
14 | 25 |
|
15 | 26 | - `make test` – run on the actual input, and compare against the expected
|
16 |
| - answers. |
17 |
| -- `make o` - same as `make test`, but first compile the .hs file using GHC |
18 |
| - with optimizations enabled. There's also a `make o2` variant of this. |
| 27 | + answers. The actual inputs should be in `input/xx`, and the expected answers |
| 28 | + in `answers/xx-a` and `answers/xx-b`. |
| 29 | +- `make o` - same as `make test`, but first compile the file using `ghc` or |
| 30 | + `swiftc` with optimizations enabled. There's also a `make o2` variant of |
| 31 | + this for Haskell that uses the `-O2` level. |
19 | 32 | - `make verify` - Run `make test`, but for all days so far, in reverse. Print
|
20 | 33 | nice and pretty stats about all the days too.
|
21 | 34 | - `make clean` - Clean temporary files (written to `out/`).
|
22 | 35 |
|
23 | 36 | To run the command on a specific day's program, just `touch` it so that it has
|
24 |
| -the latest modification time - subsequent make invocations will pick it. |
| 37 | +the latest modification time - subsequent make invocations will pick it. So for |
| 38 | +example, if I wanted to run day 18, I can |
25 | 39 |
|
26 |
| -All of these are wrappers around the basic pattern of |
| 40 | + touch 18.swift # or touch 18.hs, depending on which I wish to run |
| 41 | + make |
| 42 | + |
| 43 | +All of make invocations are wrappers around the basic pattern of |
27 | 44 |
|
28 | 45 | cat somefile | runghc xx.hs
|
29 | 46 |
|
| 47 | +and |
| 48 | + |
| 49 | + cat somefile | swift xx.swift |
| 50 | + |
30 | 51 | Some of the solutions are done in shell scripts. To run these, the filename
|
31 | 52 | needs to be passed to the script instead of passing the input via stdin:
|
32 | 53 |
|
|
0 commit comments