https://github.com/nlowe/aoc2022
Advent of Code 2022 Solutions in Go
https://github.com/nlowe/aoc2022
Last synced: 4 months ago
JSON representation
Advent of Code 2022 Solutions in Go
- Host: GitHub
- URL: https://github.com/nlowe/aoc2022
- Owner: nlowe
- License: mit
- Created: 2022-12-02T03:20:15.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-07T06:51:57.000Z (about 3 years ago)
- Last Synced: 2024-06-20T09:09:18.168Z (almost 2 years ago)
- Language: Go
- Size: 133 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Advent of Code 2022
[](https://github.com/nlowe/aoc2022/actions) [](https://coveralls.io/github/nlowe/aoc2022?branch=master) [](https://goreportcard.com/report/github.com/nlowe/aoc2022) [](./LICENSE)
Solutions for the 2022 Advent of Code
## Building
This project makes use of Go 1.19.
```bash
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:
```bash
$ go run main.go 1 a
Answer: 1532
Took 1.5586ms
```
## Adding New Solutions
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/import.go`: A "glue" file combining commands for both of the day's problems to simplify wiring up subcommands
* `challenge/day/a.go`: The main problem implementation, containing a cobra command `A` and the implementation `func a(*challenge.Input) int`
* `challenge/day/a_test.go`: A basic test template
* `challenge/day/b.go`: The main problem implementation, containing a cobra command `B` and the implementation `func b(*challenge.Input) int`
* `challenge/day/b_test.go`: A basic test template
* `challenge/day/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](./LICENSE) for details.