My solutions for the Advent of Code in NodeJS
MIT License
Each day consists of two puzzles. I added a README.md file to each Day, which contains the instructions exactly as they were displayed on https://adventofcode.com/
node -v
git clone https://github.com/NullDev/Advent-of-Code.git && cd Advent-of-Code
git checkout -b template origin/template
REPO/settings/branches
).
npm install
rm -r "./20*"
) and maybe alter the README
config.template.json
and paste it as config.json
session
cookie and paste it into the config.json
file (See here if you don't know how).
SESSION_COOKIE
with your session string.
npm run prepare-today
node prepare_day.js YEAR-DAY
- Example: node prepare_day.js 2020-12
Both of those commands will create a folder for the day/year, fetch the task from the website & convert it to a README.md, fetch the input and create template files for the solution.
Each script can be run stand-alone / separatly but I've also created a start_all.js
script to launch all days in order, and display the solutions along with an approximated benchmark (the benchmark uses performance.now()
to measure the execution time and does not include the actual reading of the file except when the file is read line-by-line).
npm run start:all
npm run start:YEAR
- Example: npm run start:2020
npm run start:YEAR DAY
- Example: npm run start:2020 3
npm run start:today
node YEAR/DAY/part_[1 OR 2].js
- Example: node 2020/01/part_2.js
Day_XX/README.md
's and Day_XX/input.txt
's) Copyright (c) Eric Wastl (@ericwastl)Day_XX/part_1.js
's and Day_XX/part_2.js
's) Copyright (c) NullDev (nulldev.org)[^1]: Unless otherwise noted in the Code
I attempted to solve every problem as functional as possible and with as little code as possible while still being performant. Some solutions could be one-liners but I left them splitted up for the sake of readability.
I also tried to experiment with a couple of different things:
2019:
2020:
2021:
O(n)
on Day 06 in both part_1 and part_2 (See the Note)2022
2023