AoC code coverage
Current view: top level - puzzles/2019 - Day09.cpp (source / functions) Coverage Total Hit
Test: master Lines: 100.0 % 22 22
Test Date: 2025-07-28 10:53:57 Functions: 100.0 % 4 4

            Line data    Source code
       1              : #include "Intcode.h"
       2              : #include "PuzzleImpl.h"
       3              : 
       4              : #include <optional>
       5              : 
       6            1 : template <> size_t part1<2019, 9>(std::string_view const input) {
       7            1 :   Computer c(input);
       8              : 
       9            1 :   std::optional<int64_t> onlyOutput;
      10            1 :   c.registerOutput([&](int64_t v) {
      11            1 :     ASSERT(!onlyOutput);
      12            1 :     onlyOutput = v;
      13            1 :   });
      14              : 
      15            1 :   c.queueInput(1);
      16            1 :   ASSERT(c.run() == Computer::HALTED);
      17              : 
      18            1 :   return onlyOutput.value_or(0);
      19            1 : }
      20              : 
      21            1 : template <> size_t part2<2019, 9>(std::string_view const input) {
      22            1 :   Computer c(input);
      23              : 
      24            1 :   std::optional<int64_t> onlyOutput;
      25            1 :   c.registerOutput([&](int64_t v) {
      26            1 :     ASSERT(!onlyOutput);
      27            1 :     onlyOutput = v;
      28            1 :   });
      29              : 
      30            1 :   c.queueInput(2);
      31            1 :   ASSERT(c.run() == Computer::HALTED);
      32              : 
      33            1 :   return onlyOutput.value_or(0);
      34            1 : }
        

Generated by: LCOV version 2.0-1