Skip to content

Commit faff257

Browse files
committed
java/2016/12: add too-long-runtime solution for part 2
The program encoded in assembunny is constructed such that running it with c == 1 takes way too long time. As such, I need to decode the program to understand what it's doing, and then implement it in Java instead.
1 parent f5a4519 commit faff257

File tree

2 files changed

+10
-18
lines changed
  • java/src
    • main/java/com/github/saser/adventofcode/year2016/day12
    • test/java/com/github/saser/adventofcode/year2016/day12

2 files changed

+10
-18
lines changed

java/src/main/java/com/github/saser/adventofcode/year2016/day12/Day12.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static Result part2(Reader r) {
1616

1717
private static Result solve(Reader r, int part) {
1818
var vm = VM.from(r);
19+
vm.c(part == 2 ? 1 : 0);
1920
vm.runAll();
2021
return Result.ok(Integer.toString(vm.a()));
2122
}

java/src/test/java/com/github/saser/adventofcode/year2016/day12/Day12Test.java

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,13 @@ public void part1Actual() throws IOException {
2727
}
2828
}
2929

30-
// @Test
31-
// public void part2Example() {
32-
// var input = new StringReader("");
33-
// var output = "";
34-
// var result = Day12.part2(input);
35-
// Assert.assertEquals("no error", "", result.error);
36-
// Assert.assertEquals("correct output", output, result.answer);
37-
// }
38-
39-
// @Test
40-
// public void part2Actual() throws IOException {
41-
// try (var input = new FileReader("inputs/2016/12")) {
42-
// var output = "";
43-
// var result = Day12.part2(input);
44-
// Assert.assertEquals("no error", "", result.error);
45-
// Assert.assertEquals("correct output", output, result.answer);
46-
// }
47-
// }
30+
@Test
31+
public void part2Actual() throws IOException {
32+
try (var input = new FileReader("inputs/2016/12")) {
33+
var output = "";
34+
var result = Day12.part2(input);
35+
Assert.assertEquals("no error", "", result.error);
36+
Assert.assertEquals("correct output", output, result.answer);
37+
}
38+
}
4839
}

0 commit comments

Comments
 (0)