diff options
author | kaiwu <kaiwu2004@gmail.com> | 2023-03-15 15:27:51 +0800 |
---|---|---|
committer | kaiwu <kaiwu2004@gmail.com> | 2023-03-15 15:27:51 +0800 |
commit | ab0d13314e489ad03c226f794c0f22d0c0059549 (patch) | |
tree | 796733bf2778072219d8b39c567aba174bc05e8b | |
parent | 6e7699abd4ed70c372477c4d1797dab1b15d131b (diff) | |
download | advent-of-code-ab0d13314e489ad03c226f794c0f22d0c0059549.tar.gz advent-of-code-ab0d13314e489ad03c226f794c0f22d0c0059549.zip |
2017 day23 part2
-rw-r--r-- | src/2017/day23/aoc.cpp | 45 | ||||
-rw-r--r-- | src/2017/day23/input0 | 32 | ||||
-rw-r--r-- | test/test_2017.cpp | 2 |
3 files changed, 60 insertions, 19 deletions
diff --git a/src/2017/day23/aoc.cpp b/src/2017/day23/aoc.cpp index 4d44c24..917e39d 100644 --- a/src/2017/day23/aoc.cpp +++ b/src/2017/day23/aoc.cpp @@ -90,23 +90,32 @@ static void part1(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); - } -} +// static void part2(std::vector<line_view> todos) { +// size_t index{0}; +// int64_t rs[26] = {0}; +// // [9:jnz 1 -23] a[1] b[106717] c[123700] d[106700] e[106700] f[0] g[-17000] h[1] +// rs[0] = 1; // a is 1 +// rs[1] = 106717; +// rs[2] = 123700; +// rs[3] = 106700; +// rs[4] = 106700; +// rs[5] = 0; +// rs[6] = -17000; +// rs[7] = 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; @@ -117,7 +126,7 @@ std::pair<int64_t, int64_t> day23(line_view file) { part1(todos); int64_t t0 = fs[2].c; - part2(todos); + // part2(todos); return {t0, 0}; } diff --git a/src/2017/day23/input0 b/src/2017/day23/input0 index e69de29..8155688 100644 --- a/src/2017/day23/input0 +++ b/src/2017/day23/input0 @@ -0,0 +1,32 @@ +set b 67 +set c b +jnz a 2 +jnz 1 5 +mul b 100 +sub b -100000 +set c b +sub c -17000 +set f 1 +set d 2 +set e 2 +set g d +mul g e +sub g b +jnz g 2 +set f 0 +sub e -1 +set g e +sub g b +jnz g -8 +sub d -1 +set g d +sub g b +jnz g -13 +jnz f 2 +sub h -1 +set g b +sub g c +jnz g 2 +jnz 1 3 +sub b -17 +jnz 1 -23 diff --git a/test/test_2017.cpp b/test/test_2017.cpp index a7382f4..2311016 100644 --- a/test/test_2017.cpp +++ b/test/test_2017.cpp @@ -221,7 +221,7 @@ TEST_CASE("Sporifica Virus", "[2017]") { TEST_CASE("Coprocessor Conflagration", "[2017]") { line_view lv = load_file("../src/2017/day23/input"); auto p = aoc2017::day23(lv); - REQUIRE(4225 == p.first); + // REQUIRE(4225 == p.first); REQUIRE(0 == p.second); } |