Skip to content

Commit c005469

Browse files
committed
adventofcode/cc: add solution for 2022/22.
Oof, this one took way too long. I wanted to create a generic solution for part 2 but eventually needed to take help from Reddit. And, when I had done that, I battled a non-deterministic bug that only showed up in <1% of test runs. When I finally found the bug (I had missed to compare the `z` coordinates in `operator==`) I didn't have enough energy to refactor the code and make it nicer. Benchmarks from `./bazel run -c opt //adventofcode/cc/year2022:day19_benchmark`: 2023-07-21T21:07:22+01:00 Running /home/saser/.cache/bazel/_bazel_saser/06ad534583e887506ca6aa175f8ed7b5/execroot/code/bazel-out/k8-opt/bin/adventofcode/cc/year2022/day22_benchmark Run on (16 X 4679.3 MHz CPU s) CPU Caches: L1 Data 32 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 512 KiB (x8) L3 Unified 16384 KiB (x1) Load Average: 1.16, 1.07, 2.06 ***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead. ----------------------------------------------------------------- Benchmark Time CPU Iterations ----------------------------------------------------------------- BM_Part1/day22.real.in 96366 ns 96287 ns 7247 BM_Part2/day22.real.in 140836 ns 140283 ns 4941
1 parent d6dffcf commit c005469

File tree

8 files changed

+882
-0
lines changed

8 files changed

+882
-0
lines changed

adventofcode/cc/year2022/BUILD.bazel

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,46 @@ cc_aoc_benchmark(
818818
},
819819
)
820820

821+
cc_library(
822+
name = "day22",
823+
srcs = ["day22.cc"],
824+
hdrs = ["day22.h"],
825+
deps = [
826+
"//adventofcode/cc:trim",
827+
"//adventofcode/cc/geometry:pos",
828+
"@com_google_absl//absl/container:flat_hash_map",
829+
"@com_google_absl//absl/log:check",
830+
"@com_google_absl//absl/status",
831+
"@com_google_absl//absl/status:statusor",
832+
"@com_google_absl//absl/strings",
833+
"@com_google_absl//absl/strings:str_format",
834+
],
835+
)
836+
837+
cc_aoc_test(
838+
name = "day22_test",
839+
library = ":day22",
840+
part1 = {
841+
"//adventofcode/data/year2022:day22.example.in": "//adventofcode/data/year2022:day22.example.part1.out",
842+
"//adventofcode/data/year2022:day22.real.in": "//adventofcode/data/year2022:day22.real.part1.out",
843+
},
844+
part2 = {
845+
"//adventofcode/data/year2022:day22.example.in": "//adventofcode/data/year2022:day22.example.part2.out",
846+
"//adventofcode/data/year2022:day22.real.in": "//adventofcode/data/year2022:day22.real.part2.out",
847+
},
848+
)
849+
850+
cc_aoc_benchmark(
851+
name = "day22_benchmark",
852+
library = ":day22",
853+
part1 = {
854+
"//adventofcode/data/year2022:day22.real.in": "//adventofcode/data/year2022:day22.real.part1.out",
855+
},
856+
part2 = {
857+
"//adventofcode/data/year2022:day22.real.in": "//adventofcode/data/year2022:day22.real.part2.out",
858+
},
859+
)
860+
821861
cc_library(
822862
name = "day23",
823863
srcs = ["day23.cc"],

0 commit comments

Comments
 (0)