diff options
Diffstat (limited to 'src/2017/day23/aoc.cpp')
-rw-r--r-- | src/2017/day23/aoc.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/2017/day23/aoc.cpp b/src/2017/day23/aoc.cpp index 7d990e3..4d44c24 100644 --- a/src/2017/day23/aoc.cpp +++ b/src/2017/day23/aoc.cpp @@ -81,7 +81,7 @@ static size_t exec(size_t index, const std::vector<line_view>& todos, int64_t rs return index; } -static void part1(const std::vector<line_view>& todos) { +static void part1(std::vector<line_view> todos) { size_t index{0}; int64_t rs[26] = {0}; @@ -90,15 +90,34 @@ static void part1(const std::vector<line_view>& todos) { } } +static void part2(std::vector<line_view> todos) { + size_t index{0}; + int64_t rs[26] = {0}; + rs[0] = 1; // a is 1 + auto print = [](int64_t is[26]) { + for (char c = 'a'; c <= 'h'; c++) { + printf("%c[%ld] ", c, is[c - 'a']); + } + printf("\n"); + }; + + while (index < todos.size()) { + std::cout << todos[index] << " "; + index = exec(index, todos, rs); + print(rs); + } +} + std::pair<int64_t, int64_t> day23(line_view file) { std::vector<line_view> todos; per_line(file, [&todos](line_view lv) { - todos.push_back(lv); + todos.push_back({lv.line, lv.length - 1}); return true; }); part1(todos); int64_t t0 = fs[2].c; + part2(todos); return {t0, 0}; } |