Solutions to the Advent of Code challenges.
Year | Days Completed | Stars Collected |
---|---|---|
2022 |
- Node.js v18.12.1+
For contributors, please use pnpm. Otherwise, feel free to use a package manager of your choice.
git clone [email protected]:dxnter/advent-of-code.git
cd advent-of-code
pnpm i
Note If you're using this project for your own solutions, the year folder(s) that contain previous solutions should be removed before use.
pnpm scaffold
# output:
# SUCCESS Puzzle files created
# + advent-of-code/src/2022/07/input.txt
# + advent-of-code/src/2022/07/day_07.ts
# + advent-of-code/src/2022/07/day_07.spec.ts
# + advent-of-code/src/2022/07/day_07.bench.ts
# ๐ Run pnpm test 2022/07 to start the test runner
# example: `pnpm scaffold 2019/20`
pnpm scaffold <year>/<day>
# output:
# SUCCESS Puzzle files created
# + advent-of-code/src/2019/20/input.txt
# + advent-of-code/src/2019/20/day_20.ts
# + advent-of-code/src/2019/20/day_20.spec.ts
# + advent-of-code/src/2019/20/day_20.bench.ts
# ๐ Run pnpm test 2019/20 to start the test runner
Once the file stubs are created, save the input for the puzzle you're solving in the input.txt
file.
Vitest is used as the test runner to validate the solutions in real-time with Watch mode. In order to benefit from this feature, the day_XX.spec.ts
file should first be updated after the input is saved.
- Update the
EXAMPLE
variable to the example text displayed on AoC. - Update the expected
equal()
value for the example in Part 1 fromtrue
to the expected value listed on AoC.
After the assertions have been updated in the test file, start the test runner with pnpm test
and begin working on the solution in day_XX.ts
. As you solve each part, the expected equal()
value should be updated after a successful submission.
Check all of the solutions:
pnpm test
Check all of the solutions for an entire year:
pnpm test 2022
Check the solutions for a specific day:
pnpm test 2022/01
To compare the performance of your solutions, the benchmarking tool in Vitest is used. Vitest runs the solution multiple times to display different performance results.
Benchmark all of the solutions:
pnpm bench
Benchmark all of the solutions for an entire year:
pnpm bench 2022
Benchmark the solutions for a specific day:
pnpm bench 2022/01