How slijkhuis/2024-advent-of-code works
Project Type and Purpose
• The project is a challenge-based repository designed to solve daily puzzles for Advent of Code 2024.
• Each puzzle (or “day”) has its own directory (named “01”, “02”, …, “25”) that contains the solution implementation and test files.
• The README instructs on how to prepare the puzzle input (“task prep”), run tests (“task test1”, “task test2”), and execute puzzle solutions (“task run1”, “task run2”).
Analyzing the File Structure
• Top-level directories:
• Directories named “01” through “25” represent individual puzzle days.
• A “pkg” directory contains shared utility code (e.g., collection utilities, parsing utilities, grid and graph handling, tree structures) that is reused across the different puzzle solutions.
• A “prep” folder includes code that helps set up or initialize the puzzle environment.
• Important configuration files and scripts:
• “Taskfile.yml” is used to automate tasks (setup, testing, execution).
• “go.mod” and “go.sum” indicate the project’s dependency management using Go modules.
System Components
a. Main Components:
• Task Runner: Represented by the Taskfile and associated commands (prep, test1, test2, run1, run2). This component orchestrates the workflow.
• Puzzle Day Modules: Each folder (“01”, “02”, …, “25”) is an encapsulated module containing main.go and one or more test files (and sometimes subdirectories like “failedattempts”).
• Utility Package (“pkg/aoc”): This is a shared library of utility functions to streamline common operations (parsing, collections, grids, etc.).
• Setup/Preparation Module: The "prep" directory, which provides startup logic to generate new puzzle templates and download the puzzle input.
• Build/System Config: This includes configuration files like “.mise.toml” and “go.mod”, which manage the build environment and dependencies.
b. Relationships and Interactions:
• The Task Runner (via Taskfile commands) triggers actions such as environment setup (“task prep”) that creates a new puzzle directory with a “main.go” template.
• Each Puzzle Day Module depends upon the shared components from the Utility Package to solve problems (data structures, parsing logic, etc.).
• The testing workflow (using tasks “test1” and “test2”) involves reading test data from manually populated test files located within each day’s folder, invoking functions (part1 and part2) defined in the main.go of respective directories.
• There is a dependency from the “prep” module and Taskfile to the file system, as the user is expected to copy test data from the puzzle text into the test files manually.
c. Architectural Patterns and Design Principles:
• Modular Design: Each day's solution is isolated into its own directory, promoting separation of concerns.
• Reusability: The “pkg” directory centralizes commonly used utility functions, reducing duplication.
• Task-Driven Workflow: The Taskfile acts as an orchestration layer, abstracting away direct command-line operations.
• Minimal yet effective structure, where each component has a clear role (puzzle solving, utility functions, and environment setup).
d. Relevant Technologies and Frameworks:
• Language: Go (indicated by main.go and go module files).
• Task Automation: Taskfile (specified in Taskfile.yml).
• Dependency Management: Go Modules (go.mod, go.sum).