{"id":20913107,"url":"https://github.com/tbe/aoc-cpp-utils","last_synced_at":"2026-04-21T12:35:22.890Z","repository":{"id":151438925,"uuid":"442540971","full_name":"tbe/aoc-cpp-utils","owner":"tbe","description":"A (growing) collection of my helper libraries, used and developed during AoC.","archived":false,"fork":false,"pushed_at":"2022-01-01T23:35:33.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-26T23:55:58.114Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tbe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-28T17:47:38.000Z","updated_at":"2022-01-01T23:35:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"8040cab2-134c-4f93-b772-3a487612dbb6","html_url":"https://github.com/tbe/aoc-cpp-utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tbe/aoc-cpp-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbe%2Faoc-cpp-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbe%2Faoc-cpp-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbe%2Faoc-cpp-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbe%2Faoc-cpp-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tbe","download_url":"https://codeload.github.com/tbe/aoc-cpp-utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbe%2Faoc-cpp-utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32092068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T11:25:29.218Z","status":"ssl_error","status_checked_at":"2026-04-21T11:25:28.499Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T14:34:51.823Z","updated_at":"2026-04-21T12:35:22.861Z","avatar_url":"https://github.com/tbe.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AoC CPP Utilities\n\nA (growing) collection of my helper libraries, used and developed during AoC.\n\n## Usage\n\nTo use this utility repo, i recommend including it via CMake like this:\n\n```cmake\ninclude(FetchContent)\nFetchContent_Declare(\n        aoc-cpp-utils\n        GIT_REPOSITORY git@github.com:tbe/aoc-cpp-utils.git\n        GIT_TAG main\n)\nFetchContent_MakeAvailable(aoc-cpp-utils)\ninclude(${aoc-cpp-utils_SOURCE_DIR}/cmake/AoC-Helpers.cmake)\n```\n\n### Write some puzzle code\n\nI didn't like copying main over and over again and duplicate cmake definitions, there are some helpers.\n\nThe puzzle solver has to provide the following interface:\n\n```c++\nstruct example {\n    example(std::istream \u0026);\n    somethingNotVoid Part1();\n    somethingNotVoid Part2();\n};\n```\n\nCreate such a `struct` or `class`, and use the following macro in your CMakeLists.txt:\n\n```cmake\n# add_aoc_executable(HEADER CLASS DAY YEAR)\nadd_aoc_executable(example.h example 01 1999)\n```\n\nThe resulting target name will be in the form of `aoc-\u003cyear\u003e-\u003cday\u003e`. You can use the usual CMake commands to add other\ndependencies for linkage, and all the stuff you are expecting to work.\n\n## Utility classes\n\n### numericGrid\n\nSome puzzles have an input in the form of an numeric grid. For example:\n\n```text\n123456789\n987654321\n111111111\n222222222\n333333333\n```\n\nOften these puzzles involve incrementing or decrementing every member, and accessing neighbours.\n\nWhile this helper can not provide the neighbour access (for now), it can help with full range changes, searches and others.\n\nHave a look at the documentation of the class, and in the test under `test/util/numericGrid.cpp`.\n\n### Dijkstra\n\nAs many puzzles are basically shorted path issues, and i did the same copy'n'paste all over the place, there is a small\nclass to help with it.\n\nThe implementation is just the core-loop and some optimized (but far from perfect) storage for this kind of problems.\n\nTo use the class, your node objects have to provide the following interface:\n\n```c++\nstruct exampleNode {\n    std::vector\u003cstd::pair\u003cYourCostValueType,exampleNode\u003e\u003e next() const;\n    // OR\n    std::vector\u003cstd::pair\u003cYourCostValueType,exampleNode\u003e\u003e next(std::pmr::memory_resource *) const;\n    \n    bool completed() const;\n};\n```\n\nTo be precise, any forward iterable container of std::pair will do. You could even have an own type, as long as it has\n`first` and `second` member variables that return costs and node objects.\n\nI have designed this interface, because it does not make any assumption on how the core problem is solved. It could be\neither self containing states, or a node object could be just a wrapper, that gets it's state from some other object. It\ndoesn't matter.\n\nHave a look in `tests/dijkstra` for such a wrapper example.\n\nThe `AoC::Dijkstra` class is a template class, here is an example how to instantiate it:\n\n```c++\nAoC::Dijkstra dijkstra\u003cNode,uint32_t,10000\u003e(initalNode, 0);\nauto [costs, winner] = dijkstra.solve();\n```\n\n### More to come\n\nI have a bunch more helper classes for repeating objects, but i wan't to clean them up, bring them to C++20, and write\nsome useful tests first before I publish them.\n\n## Test Helper\n\nMy Helpers are using googletest. While using this project does not import googletest into your project, it provides two\nhelper macros to simplify testing.\n\nA test could look like this:\n\n```c++\n#include \u003caoc-tests.h\u003e\n#include \"my-puzzle.h\"\n\nstatic const char * testdata =  \"some\\n\"\n                                \"test\\n\"\n                                \"input\";\n\nTEST(day1,Part1) {\n  TEST_PART1(Puzzle, testdata, 1234);\n}\n\n\nTEST(day1,Part2) {\n  TEST_PART2(Puzzle, testdata, 5678);\n}\n```\n\nThe input of the macro is, in order:\n- Class name for your puzzle class\n- Test input\n- Expected output\n\nThis macro does no fancy stuff. It just creates an `std::istringstream`, passes it to your class and run `Part1()` or `Part2()`.\nIt uses the google-test macros to verify the result.\n\nTo get the include path of `aoc-tests.h`, you can link against `aoc_test`. While this will add `gtest_main` to your link_libraries,\nyou are responsible to provide gtest in your project!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbe%2Faoc-cpp-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftbe%2Faoc-cpp-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbe%2Faoc-cpp-utils/lists"}