Create a new folder for the day with the necessary files.
deno task new <DayNumber>This will create the following files:
- actual.txt - put the input data for the puzzle here
- demo.txt - put the demo input from the puzzle description here
- demoSolutions.txt - put the results for the demo inputs from the puzzle description here. One line for each solutiuon for the demo input
- solution.test.ts - you can put unit tests here
- solutions.ts - your solution. Implement the two functions
solve1andsolve2.
You can create an .env-file in the root directory and put you login session cookie
from the AoC-Website in there. If the cookie is present, the tool will automatically download
the input data and put it in the actual.txt-file.
session=<YOUR SESSION COOKIE-VALUE HERE>
Remember to update your .env-file everytime you log into AoC.
deno task input <DayNumber>Fetches the input data for the given file and puts it into the respective folder. This is especially useful after cloning this repo, since we do not store the input data in the repos, just as Eric requested.
You can (re)fetch all inputs for all days present in the folder.
deno task allinputsRemember to set the session cookie info in .env to fetch data.
deno task watch <DayNumber>Watches for file changes in the days directory and reruns the tests.
This is a crude implementation and re-imports the solution module every time. as a new instance. It therefore leaks memory.
The watcher will run your solutions using the demo input. If the result matches the expectation it will rerun the solution again with the actual input.
The output looks something like this:
Rerunning Day 4
===================================================================================
Puzzle 1: 2557 (actual) - 18 (demo)
Puzzle 2: 9 (demo)
Rerunning Day 4
===================================================================================
Puzzle 1: 2557 (actual) - 18 (demo)
Puzzle 2: 1854 (actual) - 9 (demo)
deno task run <DAY>deno task runallIf you want to use unit tests/test driven development, run
deno test --watchRun it in the root directory to run tests for all days or run it in a specific folder - preferable for tdd.