/advent-of-code

TypeScript solutions for Advent of Code

Primary LanguageTypeScriptMIT LicenseMIT

Advent of Code · Build

My own entries for the Advent of Code event.

Includes a useful CLI tool to automatically fetch puzzle input and execute code.

CLI Usage

  1. Set the SESSION_COOKIE variable in a .env file, using your own session cookie from the AoC website:
# .env
SESSION_COOKIE=abcdefghijklmnopqrstuvwxyz
  1. Put your own code into one of the files in the src/days/[year] folder. The file must export 2 functions of type AoCPart, that must be named part1 and part2, and return either a string or a number as the result.
import { AoCPart } from '../../types';

export const part1: AoCPart = (input) => {
	return '[This is the result for part 1!]';
};

export const part2: AoCPart = (input) => {
	return '[This is the result for part 2!]';
};
  1. Run the program from the command line, either using the dev script or building and using the start script
# Run day 4 of the current year
$ pnpm dev run 4
# or...
$ pnpm build
$ pnpm start run 4

For more information on the available flags and options, use the help command.