Skip to content

Commit 7bf62d6

Browse files
committed
feat: add new debug cases to day 16
1 parent 1a7bf6d commit 7bf62d6

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

src/main/java/com/adventofcode/flashk/day16/ReindeerMaze.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ public long solveB(){
180180
}
181181
// Pasada 2, buscamos caminos alternativos en cada una de las intersecciones.
182182

183+
startTile.setPath(true);
184+
endTile.setPath(true);
185+
183186
paint();
184187
return countPathTiles();
185188
}
@@ -226,27 +229,16 @@ private void reset() {
226229
}
227230
}
228231

229-
private void fillPath() {
230-
Tile end = map[endPos.getY()][endPos.getX()];
231-
Tile start = map[startPos.getY()][startPos.getX()];
232-
Tile current = end;
233-
while(current != start) {
234-
current = current.getParent();
235-
current.setPath(true);
236-
}
237-
}
238-
239232
private void fillPath(Tile start, Tile end) {
240-
//Tile start = map[startPos.getY()][startPos.getX()];
241-
//Tile end = map[endPos.getY()][endPos.getX()];
242233

243234
Tile current = end;
244235
while(current != start) {
245236
current = current.getParent();
246237
current.setPath(true);
247238
}
248239

249-
end.setPath(true);
240+
start.setPath(true);
241+
250242
}
251243

252244
private Set<Tile> getAdjacents(Tile parent) {

src/test/java/com/adventofcode/flashk/common/test/constants/TestDisplayName.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ private TestDisplayName() {}
4343
public static final String PART_2_SAMPLE_5 = "Part 2 - Sample 5";
4444
public static final String PART_2_SAMPLE_6 = "Part 2 - Sample 6";
4545
public static final String PART_2_DEBUG = "Part 2 - Debug";
46+
public static final String PART_2_DEBUG_2 = "Part 2 - Debug 2";
4647

4748
public static final String PART_ONE_SINGLE_SAMPLE = "Part 1 - Single sample data";
4849
}

src/test/java/com/adventofcode/flashk/day16/Day16Test.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,45 @@ public void testSolvePart2Input() {
190190
System.out.println("Solution: "+reindeerMaze.solveB());
191191

192192
// 512 -> too low
193+
// 513 -> That's not the right answer; your answer is too low.
194+
// Curiously, it's the right answer for someone else;
195+
// you might be logged in to the wrong account or just unlucky.
196+
// 514 -> too low
193197

194198
assertEquals(0L,0L);
195199

196200
}
197201

202+
// Alternate test cases:
203+
// https://www.reddit.com/r/adventofcode/comments/1hfhgl1/2024_day_16_part_1_alternate_test_case/
204+
205+
@Test
206+
@Order(6)
207+
@Tag(TestTag.PART_2)
208+
@Tag(TestTag.INPUT)
209+
@DisplayName(TestDisplayName.PART_2_DEBUG)
210+
public void testSolvePart2Debug() {
211+
212+
// Read input file
213+
char[][] inputs = Input.read2DCharArray(INPUT_FOLDER, "debug_edge_1.input");
214+
ReindeerMaze reindeerMaze = new ReindeerMaze(inputs);
215+
216+
assertEquals(149L,reindeerMaze.solveB());
217+
218+
}
219+
220+
@Test
221+
@Order(6)
222+
@Tag(TestTag.PART_2)
223+
@Tag(TestTag.INPUT)
224+
@DisplayName(TestDisplayName.PART_2_DEBUG_2)
225+
public void testSolvePart2Debug2() {
226+
227+
// Read input file
228+
char[][] inputs = Input.read2DCharArray(INPUT_FOLDER, "debug_edge_2.input");
229+
ReindeerMaze reindeerMaze = new ReindeerMaze(inputs);
230+
231+
assertEquals(264L,reindeerMaze.solveB());
232+
233+
}
198234
}

src/test/resources/inputs

0 commit comments

Comments
 (0)