AoC code coverage
Current view: top level - puzzles/2024 - Day25.cpp (source / functions) Coverage Total Hit
Test: master Lines: 100.0 % 28 28
Test Date: 2025-12-11 19:43:23 Functions: 100.0 % 3 3

            Line data    Source code
       1              : #include "PuzzleImpl.h"
       2              : 
       3              : #include "Grid2d.h"
       4              : #include "LinewiseInput.h"
       5              : #include "Views.h"
       6              : #include "mdspan.hpp"
       7              : 
       8              : #include <vector>
       9              : 
      10              : namespace {
      11            1 : auto parse(std::string_view const input) {
      12            1 :   std::vector<uint32_t> locks;
      13            1 :   std::vector<uint32_t> keys;
      14              : 
      15          500 :   for (auto &&r : input | views::split("\n\n"sv)) {
      16          500 :     Grid2dSpan<char const> g(r.data(), 5, 7, 1, 6);
      17          500 :     uint32_t bits = 0;
      18         3000 :     for (int y = 1; y < g.ySize() - 1; ++y)
      19        15000 :       for (int x = 0; x < g.xSize(); ++x) {
      20        12500 :         bits |= g[x, y] == '#' ? 1u : 0u;
      21        12500 :         bits <<= 1u;
      22        12500 :       }
      23          500 :     if (g[0, 0] == '#')
      24          250 :       keys.push_back(bits);
      25          250 :     else
      26          250 :       locks.push_back(bits);
      27          500 :   }
      28              : 
      29            1 :   return std::make_tuple(std::move(locks), std::move(keys));
      30            1 : }
      31              : } // namespace
      32              : 
      33            1 : template <> std::string solvePart1<2024, 25>(std::string_view const input) {
      34            1 :   auto [locks, keys] = parse(input);
      35            1 :   size_t ctr = 0;
      36            1 :   for (auto l : locks)
      37          250 :     for (auto k : keys)
      38        62500 :       if ((l & k) == 0u)
      39         2854 :         ++ctr;
      40            1 :   return std::to_string(ctr);
      41            1 : }
      42              : 
      43            1 : template <> std::string solvePart2<2024, 25>(std::string_view const /* input */) { return ""s; }
        

Generated by: LCOV version 2.0-1