From 725fa439d4543c140924097ce119f9dd234f4754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Zaicsek?= Date: Sun, 17 Dec 2023 09:09:30 +0100 Subject: [PATCH] :( real solution to day 17 :'( so it turns out I was just lucky :( There is a requirement: *the ultra cart must go _at least 4 blocks_ before it can turn _or stop_* I was not filtering for this, but my solution was working for the input anyways. Reading discussions on reddit made me realize, I should add 1 more tests to my solution. I am sad now... --- .../main/java/io/github/zebalu/aoc2023/days/Day17.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aoc2023/src/main/java/io/github/zebalu/aoc2023/days/Day17.java b/aoc2023/src/main/java/io/github/zebalu/aoc2023/days/Day17.java index d4fbbac..f2c188f 100644 --- a/aoc2023/src/main/java/io/github/zebalu/aoc2023/days/Day17.java +++ b/aoc2023/src/main/java/io/github/zebalu/aoc2023/days/Day17.java @@ -12,14 +12,14 @@ public static void main(String[] args) { } private static int part1(List maze) { - return minHeatLoss(maze, 3, (a, b) -> true); + return minHeatLoss(maze, 3, (a, b) -> true, i -> true); } private static int part2(List maze) { - return minHeatLoss(maze, 10, (c, s) -> 4 <= s.straightLength() || s.pos().directionOf(c) == s.dir()); + return minHeatLoss(maze, 10, (c, s) -> 4 <= s.straightLength() || s.pos().directionOf(c) == s.dir(), i -> 4<= i); } - private static int minHeatLoss(List maze, int maxLength, BiPredicate nextFilter) { + private static int minHeatLoss(List maze, int maxLength, BiPredicate nextFilter, Predicate stopFilter) { int height = maze.size(); int width = maze.getFirst().length(); Predicate isValidCood = c -> 0 <= c.x() && 0 <= c.y() && c.x < width && c.y < height; @@ -36,7 +36,7 @@ private static int minHeatLoss(List maze, int maxLength, BiPredicate