All puzzles together run in ~50s cumulatively on my M2 MacBook Air. 🎉 The slow ones are:
- #5: p1 ~6s, p2 ~16s. (brute force md5 hashing)
- #14: p2 ~25s. (brute force md5 hashing)
Just cloned the repo? Follow these instructions to get set up.
npm install
Notice the new data
directory, created by the postinstall
(AKA setup
) script.
It should have prepopulated the folder with two blank files for each puzzle X:
puzzleX-example.txt
puzzleX-input.txt
This is where you'll add your puzzle inputs; just paste the respective contents into each file.
Tip
You can automate the data entry process by adding your session token to the .env
file.
You can find your session key in the 'session' cookie at: https://adventofcode.com.
Then run the npm run setup
command to fetch the inputs for all puzzles.
The src/index.ts
file contains a runner that will run the puzzle solutions.
You can choose to run any subset of the existing puzzle solutions. You can also choose to run either the example or main data set, or both, for any puzzle.
// await puzzle1.run();
// await puzzle2.run();
// await puzzle3.run();
// await puzzle4.run();
await puzzle5.run({
example: true,
mainProblem: false,
});
The above example will just run the example data set for puzzle 5.
Ready to start a new puzzle? Follow these instructions to generate the necessary files.
The script will automatically detect which puzzle you're on (based on existence of files in puzzles
folder), and generate the necessary files.
npm run generate
Two new (blank) puzzle data files should now exist in the data
folder:
data/puzzleX-example.ts
data/puzzleX-input.ts
Write puzzle code in new puzzle file:
src/puzzles/puzzleX.ts
Run puzzle code as needed while solving.
For a single run:
npm start
For a nodemon
file-watched run:
npm run dev
Modify runner in src/index.ts
to switch between example & main data sets for any puzzle.