Skip to content

ColeTrammer/adventofcode

Repository files navigation

Advent of Code Solutions

This repository contains my solutions to the Advent of Code challenges.

Table of Solution Completion

Year Language Number of Problems Solved Score
2024 C++ 25/25 0
2023 C++ 25/25 91
2022 Rust 25/25 0
2021 Rust 8/25 0
2020 C++ 3/25 0
2019 C++ 1/25 0

Placement on Leaderboards

2024

Day Part A Time Rank Score Part B Time Rank Score
25 00:16:12 1730 0 00:16:17 1402 0
24 00:30:22 608 0 02:40:29 1414 0
23 00:06:38 608 0 00:32:15 1400 0
22 00:07:52 947 0 00:30:15 835 0
21 01:40:48 1202 0 14:18:21 5789 0
20 00:35:21 1755 0 00:45:16 882 0
19 00:11:33 1537 0 00:12:31 901 0
18 00:14:06 1400 0 00:29:34 2323 0
17 00:22:54 1329 0 01:19:58 532 0
16 00:12:34 669 0 00:55:36 1590 0
15 00:13:41 353 0 01:12:24 1486 0
14 00:24:05 2643 0 00:39:10 1295 0
13 00:26:49 2903 0 00:41:12 1684 0
12 00:07:14 424 0 02:05:21 4382 0
11 00:16:27 4492 0 00:24:52 1853 0
10 00:06:51 505 0 00:07:22 289 0
9 00:10:24 461 0 00:21:50 262 0
8 00:09:15 588 0 00:17:19 918 0
7 00:07:05 822 0 00:09:59 736 0
6 00:07:22 620 0 00:20:07 741 0
5 00:05:55 466 0 00:12:17 564 0
4 00:15:26 2955 0 00:19:39 1648 0
3 00:09:42 4020 0 00:12:34 1687 0
2 00:04:06 262 0 00:06:26 261 0
1 00:04:00 1348 0 00:05:27 917 0

2023

Day Part A Time Rank Score Part B Time Rank Score
25 01:39:20 2154 0 01:39:24 1825 0
24 00:40:14 871 0 03:53:52 1784 0
23 00:06:13 25 76 02:30:44 1810 0
22 01:25:16 2029 0 01:38:47 1630 0
21 00:10:06 774 0 20:06:45 7843 0
20 00:47:15 850 0 00:59:15 296 0
19 00:21:30 840 0 01:01:33 989 0
18 00:14:48 435 0 03:19:33 3918 0
17 00:24:14 451 0 00:30:38 414 0
16 00:23:50 1014 0 00:30:50 999 0
15 00:03:07 377 0 00:23:21 1314 0
14 00:06:03 349 0 00:33:08 791 0
13 00:10:58 206 0 00:13:17 86 15
12 00:13:28 351 0 15:15:22 11962 0
11 00:16:28 1442 0 00:22:34 1247 0
10 00:30:53 1425 0 02:57:26 4042 0
9 00:06:15 391 0 00:10:15 649 0
8 00:10:08 2342 0 00:22:27 935 0
7 00:48:45 5358 0 01:19:15 5448 0
6 00:11:31 3410 0 00:19:28 4343 0
5 00:41:34 5078 0 01:36:57 3297 0
4 00:07:29 1838 0 00:16:50 1544 0
3 00:11:27 410 0 00:18:16 390 0
2 00:10:06 1291 0 00:11:12 721 0
1 00:08:18 4103 0 00:15:54 1155 0

2022

Day Part A Time Rank Score Part B Time Rank Score
25 00:29:04 1265 0 00:29:13 1070 0
24 00:26:27 163 0 00:34:07 211 0
23 00:46:27 1039 0 00:48:15 869 0
22 00:53:54 1298 0 >24h 7565 0
21 00:24:23 2513 0 01:10:00 2145 0
20 00:45:41 1170 0 01:03:15 1220 0
19 >24h 11606 0 >24h 11715 0
18 >24h 22983 0 >24h 18743 0
17 01:00:05 1373 0 01:16:38 588 0
16 01:33:07 1313 0 01:53:01 444 0
15 00:19:33 594 0 00:51:03 820 0
14 00:29:47 1764 0 00:35:09 1553 0
13 00:35:49 2440 0 00:47:39 2415 0
12 00:17:03 727 0 00:20:08 703 0
11 >24h 47528 0 >24h 40069 0
10 18:39:38 49715 0 18:46:07 45542 0
9 00:20:30 2047 0 00:30:48 1361 0
8 00:11:57 1218 0 00:15:21 387 0
7 00:32:24 2336 0 00:36:58 1916 0
6 00:41:00 16304 0 00:41:32 15196 0
5 00:12:54 967 0 00:17:42 1403 0
4 00:26:24 10765 0 00:27:28 8959 0
3 01:22:31 17075 0 01:30:25 15172 0
2 00:09:12 2428 0 00:13:53 2068 0
1 22:20:54 125928 0 22:27:10 120889 0

Running the Solutions

Since I created separate repositories for the years 2021 and 2022, they have been added as git submodules. Additionally, the 2023 solutions depend on my own C++ libraries, which are also included as git submodules. To clone this repository with the submodules, use the following command:

git clone --recurse-submodules https://github.com/ColeTrammer/adventofcode.git

C++ Code Organization

The source code is located in the src directory. Each day has a solution file $year/$day.cpp, in a directory of the form 01, 02, etc.

cmake --preset clang_release_default
cmake --build --preset clang_release_default

export PATH="$(realpath ./build/clang/release):$PATH"
export DAY=01
export YEAR=2023

aoc -y $YEAR -d $DAY

The input files are located in the input directory. The solution by default reads a file named input/$YEAR/input_$DAY.txt in the current working directory, but can be changed by passing the path to the input file as a command line argument:

aoc -y $YEAR -d $DAY -i input.txt

To get the solution to part b, pass the -b flag:

aoc -y $YEAR -d $DAY -b

To run against the problem provided sample input (named $YEAR/test_$DAY.txt), pass the -t flag:

aoc -y $YEAR -d $DAY -t

Utility Scripts

The scripts directory contains a number of utility scripts for interacting with the advent of code website. The scripts require an environment variable named AOC_SESSION to be set to the value of the session cookie on the advent of code website. The scripts perform the following functions:

Script Name Description
download.sh Downloads the input file for the given year and day.
new.sh Add source code and input stubs for solving a new problem day.
open.sh Opens the advent of code website for the given year, day and part in the default browser.
start.sh Calls new.sh, and then open.sh and download.sh as soon as the problem becomes available.
submit.sh Submits the solution for the given year and day. The solution is provided on stdin.

2022 Past Solutions

The rust solutions for 2022 are located in the adventofcode2022 directory. Each day has its own rust project, named day01, day02, etc. To compile and run a solution, use the following commands:

DAY=01
cd adventofcode2022/day$DAY
cargo update # This may be required if the Cargo.lock file is out of date
cargo run --release

The input files are located in the adventofcode2022/day$DAY/input.txt file. The solution defaults to reading a file named input.txt in the current working directory, but can be changed by passing the path to the input file as a command line argument:

cargo run --release -- --input input.txt

To get the solution for part b, pass the --part-b flag:

cargo run --release -- --part-b

To run against the problem provided sample input (named test.txt), pass the --test flag:

cargo run --release -- --test

2021 Past Solutions

The rust solutions for 2021 are located in the adventofcode2021 directory. Each day has its own rust project, named day1, day2, etc. To compile and run a solution, use the following commands:

DAY=1
cd adventofcode2021/day$DAY
cargo update # This may be required if the Cargo.lock file is out of date
cargo run --release

The input files are located in the adventofcode2021/day$DAY/input.txt file. The solutions are hard-coded to read a file named input.txt in the current working directory.

2020 Past Solutions

The C++ solutions for 2020 are located in the adventofcode2020 directory. The solutions files are named 1.cpp, 2.cpp, etc. To compile and run a solution, use the following commands:

DAY=1
cmake -S . -B build -G Ninja
cmake --build build
./build/$DAY

The input files are hardcoded as strings in the source code.

License

This repository is licensed under the MIT license. See the LICENSE file for more details.