diff options
author | kaiwu <kaiwu2004@gmail.com> | 2022-04-19 16:13:55 +0800 |
---|---|---|
committer | kaiwu <kaiwu2004@gmail.com> | 2022-04-19 16:13:55 +0800 |
commit | 48c40701db5a52fe7b80bc6eecca08c1447412b5 (patch) | |
tree | a7e388d6f57ee3167ca6f37f0698a772e85d994a /src/2018/day7/aoc.cpp | |
parent | 70f20b9317a11f443d01b4863969857173c63f14 (diff) | |
download | advent-of-code-48c40701db5a52fe7b80bc6eecca08c1447412b5.tar.gz advent-of-code-48c40701db5a52fe7b80bc6eecca08c1447412b5.zip |
2018 day7 part1
Diffstat (limited to 'src/2018/day7/aoc.cpp')
-rw-r--r-- | src/2018/day7/aoc.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/2018/day7/aoc.cpp b/src/2018/day7/aoc.cpp index e879fb5..6210814 100644 --- a/src/2018/day7/aoc.cpp +++ b/src/2018/day7/aoc.cpp @@ -1,4 +1,25 @@ #include "aoc.h" namespace aoc2018 { +std::map<char, instruction*> instruction::instructions = {}; + +void day7(line_view file, char sequence[]) { + per_line(file, [](line_view lv) { + char p1 = *(lv.line + 5); + char p2 = *(lv.line + 36); + instruction* i1 = instruction::make(p1); + instruction* i2 = instruction::make(p2); + i2->add_dependency(i1); + return true; + }); + + instruction* n = instruction::next(); + int i{0}; + while (n != nullptr) { + sequence[i++] = n->label; + n->make_done(); + n = instruction::next(); + } } + +} // namespace aoc2018 |