Gopher is coming to town in AoC 2023 🦫
Start by install make
on your OS:
- linux:
sudo apt-get install make
- macos:
brew install make
- windows:
choco install make
Useful commands to get you started:
- generate the daily task:
make gen
make gen day=9
make gen year=2022 day=9
By default it will generate today's task but can be changed via
year
and day
keywords.
- test the code:
make test
make test day=4 part=2
make test day=4 part=2
By default it will test today's task and part 1, but can be changed via
the day
and part
keywords.
- submit your answer
make submit
make submit day=13 part=1
By default it will submit today's task and part 1, but can be changed via
the day
and part
keywords.
The repository is structured as follows:
.
├── Makefile
├── README.md
├── cli
│ └── main.go
├── day01
│ ├── input.txt
│ ├── part1.go
│ ├── part1_test.go
│ ├── part2.go
│ └── part2_test.go
├── go.mod
├── go.sum
└── templates
└── generate_aoc.go
-
./cli/
folder is in charge of interacting with https://adventofcode.com website for i) fetching the daily input and ii) submitting input.You can try it out by running:
go run cli/main.go --help
-
./templates/
contains the go templates for generating each day. -
./dayXX/
contains the daily problems. For each part, we have a solution filepartN.go
and a corresponding test filepartN_test.go
.The test file can look like this:
func Test_solvePart1(t *testing.T) { type args struct { input func() (string, error) } tests := []struct { args args name string want int }{ { name: "solvePart1() with test input", args: args{ input: func() (string, error) { return "", nil // TODO: Add test input here. }, }, want: 0, // TODO: Add expected output here. }, }
where you have to manually add the input and answer on the TODOs. If you want to debug the
input.txt
, then just comment out thewant
field from thetest input
test case and addwant: 1
to theinput.txt
test case.
+---------------------------------------------+
| Benchmark Results AoC 2023 |
+-------+------+----------------+-------------+
| DAY | PART | ANSWER | TIME |
+-------+------+----------------+-------------+
| day01 | 1 | 54644 | 240.278µs |
| | | | |
| | 2 | 53348 | 2.973872ms |
| | | | |
| day02 | 1 | 2169 | 192.199µs |
| | | | |
| | 2 | 60948 | 273.45µs |
| | | | |
| day03 | 1 | 527364 | 6.84216ms |
| | | | |
| | 2 | 79026871 | 5.721963ms |
| | | | |
| day04 | 1 | 21158 | 427.507µs |
| | | | |
| | 2 | 6050769 | 408.992µs |
| | | | |
| day06 | 1 | 1660968 | 11.721µs |
| | | | |
| | 2 | 26499773 | 30.572795ms |
| | | | |
| day07 | 1 | 253603890 | 1.261921ms |
| | | | |
| | 2 | 253630098 | 1.402404ms |
| | | | |
| day08 | 1 | 19199 | 3.449268ms |
| | | | |
| | 2 | 13663968099527 | 7.43219ms |
| | | | |
| day09 | 1 | 1887980197 | 4.063813ms |
| | | | |
| | 2 | 990 | 6.171931ms |
| | | | |
+-------+------+----------------+-------------+
Benchmark table is generated by CI/CD or run make benchmark
.