Solutions for Advent Of Code 2022 written in C
The descriptions of the daily tasks are in the comments in the *.c
files (see src/
).
The *.txt
files in input/
contain the original input for the tasks.
main.exe
does all tasks and prints all solutions. It uses the input files in input/
.
Use GCC to build main.c
with the makefile provided.
Day | Part 1 | Part 2 |
---|---|---|
Day 1 | ⭐ | ⭐ |
Day 2 | ⭐ | ⭐ |
Day 3 | ⭐ | ⭐ |
Day 4 | ⭐ | ⭐ |
Day 5 | ⭐ | ⭐ |
Day 6 | ⭐ | ⭐ |
Day 7 | ⭐ | ⭐ |
Day 8 | ⭐ | ⭐ |
Day 9 | ⭐ | ⭐ |
Day 10 | ⭐ | ⭐ |
Day 11 | ⭐ | ⭐ |
Done with hyperfine (see file benchmark.bat
)
Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
---|---|---|---|---|
benchmark\adv1.exe |
3.0 ± 1.1 | 1.9 | 9.9 | 5.08 ± 5.57 |
benchmark\adv2.exe |
3.6 ± 1.3 | 2.0 | 9.8 | 6.05 ± 6.63 |
benchmark\adv3.exe |
2.4 ± 0.9 | 0.6 | 5.8 | 3.96 ± 4.39 |
benchmark\adv4.exe |
1.9 ± 1.2 | 0.7 | 8.3 | 3.26 ± 3.96 |
benchmark\adv5.exe |
2.6 ± 1.5 | 0.9 | 8.2 | 4.40 ± 5.20 |
benchmark\adv6.exe |
2.6 ± 1.7 | 0.8 | 10.6 | 4.29 ± 5.31 |
benchmark\adv7.exe |
0.6 ± 0.6 | 0.0 | 4.4 | 1.00 |
- Install Mingw
- Add
C:\MinGW\bin
to PATH - Symlink
mklink C:\MinGW\bin\make.exe C:\MinGW\bin\mingw32-make.exe
- In SublimeText Tools > Build System > New Build System...
- Add the following code (also found in Make_AOC.sublime-build)
{ "shell_cmd": "make", "working_dir": "${folder}", "variants": [ { "name": "Run", "shell_cmd": "make && ${folder}/main.exe skip" }, { "name": "Clean", "shell_cmd": "make clean" } ] }
- Save to
C:\Users\[$user]\AppData\Roaming\Sublime Text 3\Packages\User
- Add the following code (also found in Make_AOC.sublime-build)
- Select this Build System in Tools > Build System
- Build with Ctrl + B
- Ctrl + Shift + B to choose variant (e.g run)
All solutions have the same base structure.
There is a snippet for SublimeText to generate this basic structure.
Just type AOC
and hit Tab to insert the basic code.
To use it, place AOC.sublime-snippet
in C:\Users\<UserName>\AppData\Roaming\Sublime Text 3\Packages\User
Auto-generate a release with the workflow found in .github/workflows/
git tag -a v* -m "My_Msg"
git push --tags
To solve puzzles, put the input data given by the calendar in a txt file for each day(e.g. 3.txt
for Day 3).
Place the txt files in an fodler called input
. The folder must be under the same path as the main executeable.
The same can be done for the samples of each puzzle in a folder named samples
.
run main
to solve the puzzles with the data from input
folder.
run main sample
to solve the puzzles with the data from samples
folder.