Skip to content

Commit 84c1e15

Browse files
committed
java/2016/16: add solution for part 2
1 parent 14ea84f commit 84c1e15

File tree

2 files changed

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

2 files changed

+10
-19
lines changed

java/src/main/java/com/github/saser/adventofcode/year2016/day16/Day16.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static Result part2(Reader r) {
1818
private static Result solve(Reader r, int part) {
1919
try {
2020
var state = Day16.parse(r);
21-
state = Day16.generate(state, 272);
21+
state = Day16.generate(state, part == 1 ? 272 : 35651584);
2222
var checksum = Day16.checksum(state);
2323
return Result.ok(Day16.toString(checksum));
2424
} catch (Exception e) {

java/src/test/java/com/github/saser/adventofcode/year2016/day16/Day16Test.java

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

21-
// @Test
22-
// public void part2Example() {
23-
// var input = new StringReader("");
24-
// var output = "";
25-
// var result = Day16.part2(input);
26-
// Assert.assertEquals("no error", "", result.error);
27-
// Assert.assertEquals("correct output", output, result.answer);
28-
// }
29-
30-
// @Test
31-
// public void part2Actual() throws IOException {
32-
// try (var input = new FileReader("inputs/2016/16")) {
33-
// var output = "";
34-
// var result = Day16.part2(input);
35-
// Assert.assertEquals("no error", "", result.error);
36-
// Assert.assertEquals("correct output", output, result.answer);
37-
// }
38-
// }
21+
@Test
22+
public void part2Actual() throws IOException {
23+
try (var input = new FileReader("inputs/2016/16")) {
24+
var output = "01010100101011100";
25+
var result = Day16.part2(input);
26+
Assert.assertEquals("no error", "", result.error);
27+
Assert.assertEquals("correct output", output, result.answer);
28+
}
29+
}
3930
}

0 commit comments

Comments
 (0)