Skip to content

Commit 6ca78f9

Browse files
committed
java/2016/15: add solution for part 2
1 parent bbc25e8 commit 6ca78f9

File tree

2 files changed

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

2 files changed

+12
-18
lines changed

java/src/main/java/com/github/saser/adventofcode/year2016/day15/Day15.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public static Result part2(Reader r) {
2121

2222
private static Result solve(Reader r, int part) {
2323
var discs = Day15.parse(r);
24+
if (part == 2) {
25+
discs.add(new Tuple3<>(discs.size() + 1L, 11L, 0L));
26+
}
2427
var equations = discs.stream()
2528
.map(tuple -> {
2629
var disc = tuple.v1;

java/src/test/java/com/github/saser/adventofcode/year2016/day15/Day15Test.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 = Day15.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/15")) {
42-
// var output = "";
43-
// var result = Day15.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/15")) {
33+
var output = "2353212";
34+
var result = Day15.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)