Skip to content

πŸŽ„ My solutions and TypeScript project template for Advent of Code 2024!

License

Notifications You must be signed in to change notification settings

goosewin/aoc2024

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Advent of Code 2024 Solutions

Solutions runner for Advent of Code 2024 puzzles, built with Typescript and Bun.

Prerequisites

Setup

  1. Clone this repository

  2. Install dependencies:

    bun install

Project Structure

.
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ XX-solution.ts    # Daily solution files (XX = day number)
β”‚   β”œβ”€β”€ XX-input          # Daily input files
β”‚   β”œβ”€β”€ XX-problem.md     # Problem descriptions
β”‚   └── common.ts         # Shared utilities
β”œβ”€β”€ index.ts              # CLI runner
└── package.json

Usage

Run solution for a specific day

# Run both parts for a day
bun start 1

# Run a specific part
bun start 1 --part 1
bun start 1 -p 2

Run all solutions

bun start

Solution Format

Each daily solution should be placed in the src directory following the naming convention XX-solution.ts (where XX is the zero-padded day number). Solutions use the withTiming wrapper to automatically measure and display execution time.

Example solution file (01-solution.ts):

import { readInput, withTiming } from "./common";

export const part1 = async () => withTiming(async () => {
    const input = await readInput("01");
    // Solution implementation
    return result;
});

export const part2 = async () => withTiming(async () => {
    const input = await readInput("01");
    // Solution implementation
    return result;
});

Features

  • πŸš€ Fast execution with Bun runtime
  • πŸ“Š Automatic performance timing for solutions
  • 🎯 Run specific parts or days
  • πŸ”„ Automatic input file loading
  • πŸ’ͺ TypeScript support
  • πŸ“ Common utilities for parsing and timing

License

MIT