December means Advent of Code for many of us 🎄 (or at least, the first few days of December)
These funny challenges require a few steps every day, from setting up the new empty solution files to manually downloading the inputs and submitting the solution.
What if the manual/repetitive steps could be automated? 🤔 It's a game made by developers for developers (developers developers) and depending on your language there are some so-called runners to give some automation 🤖
This is the original repo: https://github.com/caderek/aocrunner
I mean... what do you even need to automate? The game isn't just getting the input and running a js/ts file?
Yeah, but we love automating things, so here's what this tool does:
- Define a common template to handle the input file and both solutions
- Create the folder with the files you need for the challenge
- Download the input file
- Run the solution locally
- Submit the solution
You can also quickly run some custom tests and other nice to have features.
I recorded a demo where I show it in action, you can find it here or on YouTube:
Here below you can find all the main steps anyway, in case you don't want to watch the video :)
Basically a command lets you create the initial project with some other handy features in the
scripts section of the
As written in the README, you can run a command that will create a folder containing all the files you need for the challenge:
npx aocrunner init
A simple CLI installer will ask you for some questions (like the year, js/ts, folder name, etc) and then it will create the folder with the files.
All inputs are different for each user, which means you need somehow to authenticate to the website to download the input file.
Everything happens under the hood, all you need to do is to feed the tool with your session cookie, which you can find in the browser from the "Application" tab of the dev tools.
Put it inside the
.env file in the root of the project and that's it! (In the video I show it step by step)
To run the challenges for a day, you can use the
npm run start 1
If it's the first time you run it, it will download the input file and create the js/ts file to run the solution in a new folder.
Otherwise, it will just run & watch the solution to evaluate the result every time you save the file.
While you're running it with the
run command, you can also submit the solution by pressing
s in the terminal.
There are also some other features I'd recommend you to try, but one thing it's also worth mentioning is that unfortunately the original project seems inactive.
It works fine so I'm happy to talk about it, but if you're using other runners or you made one, feel free to share it in the comments below!
Happy Advent of Code! 🎄
Thanks for reading this article, I hope you found it interesting!
I recently launched my Discord server to talk about Open Source and Web Development, feel free to join: https://discord.gg/bqwyEa6We6
Feel free to follow me to get notified when new articles are out ;)