Skip to content
/ aoc2023 Public

Advent of Code 2023 Solutions in Go

License

Notifications You must be signed in to change notification settings

nlowe/aoc2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advent of Code 2023

Coverage Status Go Report Card License

Solutions for the 2023 Advent of Code

Building

This project makes use of Go 1.21.

go mod download
go test ./...

Running the Solutions

To run a solution, use the problem name followed by the path to an input file.

For example, to run problem 2a:

$ go run main.go 1 a
Answer: 1532
Took 1.5586ms

Adding New Solutions

This currently requires the environment variable AOC_SESSION_TOKEN be set with your AdventOfCode session token.

A generator program is included that makes templates for each day, automatically downloading challenge input and updating the root command to add new subcommands for each problem. Running go generate from the repo root will generate the following for each day that is currently accessible:

  • challenge/day<N>/import.go: A "glue" file combining commands for both of the day's problems to simplify wiring up subcommands
  • challenge/day<N>/a.go: The main problem implementation, containing a cobra command A and the implementation func a(*challenge.Input) int
  • challenge/day<N>/a_test.go: A basic test template
  • challenge/day<N>/b.go: The main problem implementation, containing a cobra command B and the implementation func b(*challenge.Input) int
  • challenge/day<N>/b_test.go: A basic test template
  • challenge/day<N>/input.txt: The challenge input

Additionally, challenge/cmd/cmd.go will be regenerated to import and add all subcommands.

This requires goimports be available on your $PATH. Additionally, you must be logged into https://adventofcode.com in Chrome so the generator can use your session cookie to download challenge input.

Existing solutions and challenge inputs will be skipped instead of regenerated.

License

These solutions are licensed under the MIT License.

See LICENSE for details.

About

Advent of Code 2023 Solutions in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages