Build system: Bazel
I included my .bazelrc
for MacOS 14, C++ 17. You might have to change that for your system.
Look at the BUILD
file for different targets, ("day1", "day2", etc).
I put a bunch of effort into Day 1 to try to be somewhat optimal. By Day 3, I'm now just trying to solve and move on :)
Read a file, and for each line, find the first digit from the left and from the right, either by itself or spelled out ("one", "two", "three"), put the two digits together ("1abc2"" gives you "12"), then add up all the lines for a final answer.
Note: I went a little overboard trying to be optimal on this one :)
bazel run //:day1 -- --input_file=input/day1/input.txt
Read a file that represents someone reaching into a bag of dice and making several rolls per short game. Figure out some info about possible counts of different colors in that bag based on the rolls seen that game.
bazel run //:day2 -- --input_file=input/day2/input.txt
Read a file that has a block of text that includes periods, digits, and special characters. Sum the numbers that are neighboring a special character (same line, or prev/next, including diagonal). In addition, if a special character is an asterisk, and neighbors exactly two numbers, multiply those numbers together and keep a separate running sum of these "gear ratios".
bazel run //:day3 -- --input_file=input/day3/input.txt
Read a file that represents scratch-off cards, one card per line. Each line has a card number, followed
by winning numbers, a |
, and then the numbers in play. Part 1 and 2 have different methods for
calculating the number of points you win.
bazel run //:day4 -- --input_file=input/day4/input.txt
Read a file that represents a way to find which seeds can be planted in which locations. Parse the file and walk through the different source-to-dest mappings from seed to soil, fertilizer, water, light, temperature, humidity, and ultimately, location.
bazel run //:day5 -- --input_file=input/day5/input.txt