My solutions to the 2021 edition of Advent of Code.
Day | Code | Part 1 | Part 2 |
---|---|---|---|
01 | solution | 00:01:33 / 319 |
00:14:03 / 3652 |
02 | solution | 00:02:18 / 414 |
00:05:03 / 899 |
03 | solution | 00:12:08 / 3949 |
00:36:11 / 3416 |
04 | solution | 00:15:35 / 678 |
00:22:21 / 807 |
05 | solution | ||
06 | solution | 00:04:39 / 486 |
00:10:34 / 535 |
07 | solution | 00:04:27 / 1117 |
00:06:07 / 557 |
08 | solution | 00:13:22 / 3326 |
00:21:17 / 106 |
09 | solution | 00:05:45 / 456 |
00:19:51 / 716 |
10 | solution | 00:07:37 / 826 |
00:26:13 / 2916 |
11 | solution | 00:21:48 / 1483 |
00:23:34 / 1315 |
12 | solution | 00:23:24 / 1959 |
00:36:16 / 1698 |
13 | solution | 00:14:32 / 950 |
00:15:15 / 410 |
14 | solution | 00:11:07 / 1055 |
01:02:12 / 2966 |
15 | solution | 00:51:52 / 3469 |
01:19:39 / 2672 |
16 | solution | 00:24:39 / 171 |
00:44:47 / 576 |
17 | solution | 00:12:12 / 321 |
00:19:30 / 401 |
18 | solution | 01:50:25 / 1389 |
01:52:16 / 1259 |
19 | solution | 03:20:15 / 1516 |
03:32:21 / 1432 |
20 | solution | 00:16:42 / 107 |
01:12:12 / 2295 |
21 | solution | 00:09:42 / 615 |
00:26:00 / 237 |
22 | solution | 00:11:01 / 636 |
05:16:46 / 3011 |
23 | solution | 01:25:24 / 1225 |
09:57:37 / 3452 |
24 | solution | ||
25 | solution |
The third and last row indicate the time and rank I obtained for that part. Empty cells mean no participation.
In order to make the challenge more interesting, I set myself the following rules:
- Pure: no usage of
var
or mutable datastructures - Self-contained: no third-party libraries, one file per day (*)
- Efficient: optimal asymptotic complexity, as far as reasonable
- Concise: readability is key
Note that these rules do not necessarily apply while solving a problem, but rather when committing the code to this repository.
(*): this rule could be subject to modification, for instance if the puzzles implicitly require it (Intcode in 2019).
This project runs on Scala 3.0.2
and sbt 1.5.5
.
Use the following template to write a solution for a given day:
package adventofcode.solutions
import adventofcode.Definitions.*
@main def Day01 = Day(1) { (input, part) =>
part(1) = ???
part(2) = ???
}
(change 1
to the current day number and fill in the ???
)
Paste your input as a file named 01.txt
in input/
.
To run the code, enter sbt run Day01
.
The output(s) will be printed to the console and stored in output/
as 01-1.txt
and 01-2.txt
.
Additionally, the command sbt test
will run all the implemented solutions and compare their result against the currently stored output, to detect any potential regression.
MIT