Welcome to my Advent of Code automation and solutions repository! This project helps you fetch puzzle inputs, generate solution boilerplate, and streamline your AoC workflow.
This repo automates the Advent of Code experience:
- Can fetch daily puzzle input and description
- Generates TypeScript boilerplate for each day's solutions
- Organizes everything by year and day
- Lets you submit answers and track progress
- Clone the repository:
git clone https://github.com/nturf/AOC.git cd AOC npm install
- set
AOC_SESSION=
in .env - Here's how to find your session cookie
-
./aoc get <year> <day>
Fetches the problem input and description for the given year and day. -
./aoc sub <year> <day>
Submits your solution for the given year and day.
Tip: You usually don't need to specify the year every time. The default year is set to 2015
.
- To change the default year, edit the
DEFAULT_AOC_YEAR=2015
field in theaoc
script. - Then you can use:
./aoc get <day>
./aoc sub <day>
When you run the commands, the following structure is created:
year/dayXX/
βββ input.txt # The input for the problem
βββ README.md # Contains the Puzzle text
βββ part1.ts # Solution for part 1
βββ part2.ts # Solution for part 2
βββ test.ts # Test cases for the solution
βββ meta.json # Metadata for the problem
-
Fetching a Problem:
- Run
./aoc get <day>
(or with year) to download the day's input and description. - The script creates the folder and boilerplate files for you.
- Run
-
Solving Part 1:
- Open
part1.ts
. The generated boilerplate typically looks like:export default function solve(input: string): number | string { // Your solution here }
- The
input
parameter contains the contents ofinput.txt
as a string. - Write your solution logic using this input.
- Open
-
Testing:
- Use
test
to write and run test cases for your solutions. ts-node test.ts
will give the output for you solution.
- Use
-
Submitting part1:
- Run
./aoc sub <day>
(or with year) to submit your answer. The script will use your solution and input automatically. soon after the submission on part1, part2 will be fetched in yourREADME.md
- Run
-
Solving Part 2:
- Open
part2.ts
. The structure is the same as part 1, ready for your code.
- Open
-
Test & Submit:
- Run
ts-node test.ts
to test solution and run./aoc sub <day>
to submit part2
- Run
If you have any questions or suggestions, feel free to reach out:
- Twitter: @nturfff