A simple CLI tool to organize and solve Advent of Code problems. It handles downloading inputs, generating boilerplate code, and running your solutions, so you can focus on the logic.
- Project Initialization: Sets up a clean workspace for your AoC solutions.
- Synchronization: Downloads puzzle descriptions (README.md) and inputs for all available days.
- Code Generation: Generates simple Go boilerplate for each day.
- Zero Friction: No complex interfaces to implement. Just write
Part1andPart2functions.
go install github.com/dolfolife/aoctl@latestStart by creating a new directory for your Advent of Code solutions and initializing it:
mkdir my-aoc-solutions
cd my-aoc-solutions
aoctl init .To download inputs, you need to provide your Advent of Code session cookie. You can find this in your browser's developer tools (Application -> Cookies) when logged into adventofcode.com.
aoctl session --session <your-session-cookie>Download the puzzles and generate the boilerplate code for the current year (or previous years).
aoctl synchronizeThis will create a directory structure like this:
events/
2024/
01/
README.md # The puzzle description
input/
input.txt # The puzzle input
main.go # Entry point to run your solution
solution.go # Where you write your code
solution_test.go # Tests for your solution
Open events/2024/01/solution.go and implement Part1 and Part2.
package main
func Part1(input string) (string, error) {
// Your logic here
return "answer", nil
}
func Part2(input string) (string, error) {
// Your logic here
return "answer", nil
}Run your solution:
cd events/2024/01
go run .Run tests:
go test .The pkg/puzzle package provides a simple helper to read the input file:
import "github.com/dolfolife/aoctl/pkg/puzzle"
input, err := puzzle.ReadInput("input/input.txt")PRs are welcome! Please check CONTRIBUTING.md for guidelines.