My solutions to the advent of code 2023
Day | Task 1 | ᴍs | Task 2 | ᴍs | Total Execution Time (ᴍs) |
---|---|---|---|---|---|
1 | 56465 | 0.534 | 55902 | 5.001 | 5.535 |
2 | 2617 | 0.294 | 59795 | 0.248 | 0.542 |
3 | 535351 | 1.962 | 87287096 | 0.348 | 2.31 |
4 | 25183 | 1.223 | 5667240 | 1.261 | 2.484 |
5 | 324724204 | 0.908 | 104070862 | 81013.363 | 81014.704 |
6 | 1195150 | 0.017 | 42550411 | 44.144 | 44.162 |
7 | 248559379 | 4.938 | 249631254 | 7.643 | 12.581 |
8 | 21389 | 56.578 | 21083806112641 | 187427.929 | 187484.859 |
9 | 2098530125 | 1.068 | 1016 | 0.95 | 2.017 |
10 | 6867 | 2199.595 | 595 | 276687.885 | 278887.919 |
11 | 9550717 | 3.763 | 648458253817 | 3.236 | 6.999 |
12 | 7173 | 4337.034 | ❌ | 0 | 4337.034 |
13 | 29846 | 0.262 | 25401 | 0.648 | 0.91 |
14 | 108144 | 1.719 | 108404 | 628.327 | 630.045 |
15 | 508498 | 0.582 | 279116 | 2.384 | 2.967 |
16 | 7046 | 275.595 | 7313 | 63377.75 | 63653.765 |
17 | ❌ | 0 | ❌ | 0 | 0 |
18 | 56678 | 1242.349 | 79088855654037 | 406.834 | 1649.481 |
19 | 362930 | 3.148 | 116365820987729 | 48593.081 | 48596.67 |
20 | 670984704 | 11.504 | ❌ | 0 | 11.504 |
21 | 3574 | 269.225 | -1 | 0.002 | 269.227 |
Create a .env
file containing session=COOKIE
(where COOKIE
is your AoC cookie). This is used for downloading the puzzle input.
The goal is to not use any external modules, only those built in to the node runtime (this means no package.json). Node v12 and above should work for the puzzles (node index
), but v18 is required for node index download day
for the newly supported fetch API
index.js
in the root directory contains a basic test runner to run each day's tasks and compare answers. This file will be updated with new days as they come.
node index
to run the benchmark.node index download day
to setup a day's files
node index
Returns output in the format of
Day X
------
Task A is Correct (ANSWER) (took Zms)
Task B is Wrong (expected EXPECTED but got ACTUAL) (took Zms)
Each day will output an array of objects ([{ms: number, ans: object}]) representing the result of each task within that day.
The test runner knows what the answers should be, these are stored in an array of arrays with each array representing the answers for each day.
For example
[[DAY 1 TASK 1 ANSWER, DAY 1 TASK 2 ANSWER], [DAY 2 TASK 1 ANSWER], ...]
We iterate through all the days we have loaded and compare their answers. We ouput whether the answer was right or wrong (and what we got if it was wrong). console.log
is used for correct answers and console.error
is used for wrong answers to give colour (if using a command line environment that allows for colour)