AoC code coverage
Current view: top level - puzzles/2015 - Day01.cpp (source / functions) Coverage Total Hit
Test: master Lines: 91.7 % 12 11
Test Date: 2025-07-28 10:53:57 Functions: 100.0 % 2 2

            Line data    Source code
       1              : #include "PuzzleImpl.h"
       2              : 
       3              : #include <libassert/assert.hpp>
       4              : 
       5              : #include <algorithm>
       6              : #include <iostream>
       7              : 
       8            1 : template <> size_t part1<2015, 1>(std::string_view const input) {
       9            1 :   return 2 * std::ranges::count(input, '(') - input.size();
      10            1 : }
      11              : 
      12            1 : template <> size_t part2<2015, 1>(std::string_view const input) {
      13            1 :   int floor = 0;
      14         1771 :   for (size_t pos = 0; pos < input.size(); ++pos) {
      15         1771 :     floor += (input[pos] == '(') ? 1 : -1;
      16         1771 :     if (floor == -1)
      17            1 :       return pos + 1;
      18         1771 :   }
      19            1 :   UNREACHABLE();
      20            0 : }
        

Generated by: LCOV version 2.0-1