File tree Expand file tree Collapse file tree 2 files changed +26
-19
lines changed
main/java/com/github/saser/adventofcode/year2016/day10
test/java/com/github/saser/adventofcode/year2016/day10 Expand file tree Collapse file tree 2 files changed +26
-19
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,23 @@ private static Result solve(Reader r, int part) {
31
31
var bot = visited61 .iterator ().next ();
32
32
return Result .ok (Integer .toString (bot ));
33
33
}
34
- return Result .err ("not implemented yet" );
34
+ var product = 1 ;
35
+ var found = new boolean [3 ];
36
+ for (var entry : paths .entrySet ()) {
37
+ var list = entry .getValue ();
38
+ var output = list .get (list .size () - 1 );
39
+ if (output >= 0 && output <= 2 ) {
40
+ if (found [output ]) {
41
+ continue ;
42
+ }
43
+ found [output ] = true ;
44
+ product *= entry .getKey ();
45
+ }
46
+ if (found [0 ] && found [1 ] && found [2 ]) {
47
+ break ;
48
+ }
49
+ }
50
+ return Result .ok (Integer .toString (product ));
35
51
}
36
52
37
53
private static class Network {
Original file line number Diff line number Diff line change @@ -17,22 +17,13 @@ public void part1Actual() throws IOException {
17
17
}
18
18
}
19
19
20
- // @Test
21
- // public void part2Example() {
22
- // var input = new StringReader("");
23
- // var output = "";
24
- // var result = Day10.part2(input);
25
- // Assert.assertEquals("no error", "", result.error);
26
- // Assert.assertEquals("correct output", output, result.answer);
27
- // }
28
-
29
- // @Test
30
- // public void part2Actual() throws IOException {
31
- // try (var input = new FileReader("inputs/2016/10")) {
32
- // var output = "";
33
- // var result = Day10.part2(input);
34
- // Assert.assertEquals("no error", "", result.error);
35
- // Assert.assertEquals("correct output", output, result.answer);
36
- // }
37
- // }
20
+ @ Test
21
+ public void part2Actual () throws IOException {
22
+ try (var input = new FileReader ("inputs/2016/10" )) {
23
+ var output = "143153" ;
24
+ var result = Day10 .part2 (input );
25
+ Assert .assertEquals ("no error" , "" , result .error );
26
+ Assert .assertEquals ("correct output" , output , result .answer );
27
+ }
28
+ }
38
29
}
You can’t perform that action at this time.
0 commit comments