From c06bd13b3419c924bd98be2f50ee361074a6d6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Belellou?= Date: Sat, 23 Nov 2024 20:37:03 +0100 Subject: [PATCH] Added 2015 Day 11 --- .../advent/generic/AbstractDaySolver.java | 14 +-- .../belellou/kevin/advent/generic/Day0.java | 10 +- .../kevin/advent/generic/DaySolver.java | 10 +- .../belellou/kevin/advent/year2015/Day1.java | 10 +- .../belellou/kevin/advent/year2015/Day10.java | 10 +- .../belellou/kevin/advent/year2015/Day11.java | 109 ++++++++++++++++++ .../belellou/kevin/advent/year2015/Day2.java | 10 +- .../belellou/kevin/advent/year2015/Day3.java | 10 +- .../belellou/kevin/advent/year2015/Day4.java | 10 +- .../belellou/kevin/advent/year2015/Day5.java | 10 +- .../belellou/kevin/advent/year2015/Day6.java | 10 +- .../belellou/kevin/advent/year2015/Day7.java | 10 +- .../belellou/kevin/advent/year2015/Day8.java | 10 +- .../belellou/kevin/advent/year2015/Day9.java | 10 +- src/main/resources/2015/11/input.txt | 1 + .../belellou/kevin/advent/DaySolverTest.java | 10 +- 16 files changed, 182 insertions(+), 72 deletions(-) create mode 100644 src/main/java/com/belellou/kevin/advent/year2015/Day11.java create mode 100644 src/main/resources/2015/11/input.txt diff --git a/src/main/java/com/belellou/kevin/advent/generic/AbstractDaySolver.java b/src/main/java/com/belellou/kevin/advent/generic/AbstractDaySolver.java index 6e112c9..a156f8c 100644 --- a/src/main/java/com/belellou/kevin/advent/generic/AbstractDaySolver.java +++ b/src/main/java/com/belellou/kevin/advent/generic/AbstractDaySolver.java @@ -5,7 +5,7 @@ import java.io.FileReader; import java.io.IOException; -public abstract class AbstractDaySolver implements DaySolver { +public abstract class AbstractDaySolver implements DaySolver { private static final String SEPARATOR = "/"; private static final String INPUT_FOLDER = "src/main/resources/"; @@ -36,9 +36,9 @@ private BufferedReader getReader() { } @Override - public int solveFirstStar() { + public T solveFirstStar() { try (BufferedReader reader = getReader()) { - int firstSolution = doSolveFirstStar(reader); + T firstSolution = doSolveFirstStar(reader); System.out.println(this + FIRST_SOLUTION + firstSolution); @@ -49,9 +49,9 @@ public int solveFirstStar() { } @Override - public int solveSecondStar() { + public T solveSecondStar() { try (BufferedReader reader = getReader()) { - int secondSolution = doSolveSecondStar(reader); + T secondSolution = doSolveSecondStar(reader); System.out.println(this + SECOND_SOLUTION + secondSolution); @@ -61,9 +61,9 @@ public int solveSecondStar() { } } - protected abstract int doSolveFirstStar(BufferedReader reader) throws IOException; + protected abstract T doSolveFirstStar(BufferedReader reader) throws IOException; - protected abstract int doSolveSecondStar(BufferedReader reader) throws IOException; + protected abstract T doSolveSecondStar(BufferedReader reader) throws IOException; @Override public String toString() { diff --git a/src/main/java/com/belellou/kevin/advent/generic/Day0.java b/src/main/java/com/belellou/kevin/advent/generic/Day0.java index 4e18c9b..809557c 100644 --- a/src/main/java/com/belellou/kevin/advent/generic/Day0.java +++ b/src/main/java/com/belellou/kevin/advent/generic/Day0.java @@ -3,31 +3,31 @@ import java.io.BufferedReader; @SuppressWarnings("unused") -public class Day0 extends AbstractDaySolver { +public class Day0 extends AbstractDaySolver { public Day0() { super(Year.YEAR_0, Day.DAY_0); } @Override - protected int doSolveFirstStar(BufferedReader reader) { + protected Integer doSolveFirstStar(BufferedReader reader) { return 0; } @DisableTest @Override - public int getFirstStarSolution() { + public Integer getFirstStarSolution() { return 0; } @Override - protected int doSolveSecondStar(BufferedReader reader) { + protected Integer doSolveSecondStar(BufferedReader reader) { return 0; } @DisableTest @Override - public int getSecondStarSolution() { + public Integer getSecondStarSolution() { return 0; } } diff --git a/src/main/java/com/belellou/kevin/advent/generic/DaySolver.java b/src/main/java/com/belellou/kevin/advent/generic/DaySolver.java index 63d7c46..a5c3dbb 100644 --- a/src/main/java/com/belellou/kevin/advent/generic/DaySolver.java +++ b/src/main/java/com/belellou/kevin/advent/generic/DaySolver.java @@ -1,12 +1,12 @@ package com.belellou.kevin.advent.generic; -public interface DaySolver { +public interface DaySolver { - int solveFirstStar(); + T solveFirstStar(); - int getFirstStarSolution(); + T getFirstStarSolution(); - int solveSecondStar(); + T solveSecondStar(); - int getSecondStarSolution(); + T getSecondStarSolution(); } diff --git a/src/main/java/com/belellou/kevin/advent/year2015/Day1.java b/src/main/java/com/belellou/kevin/advent/year2015/Day1.java index b10b039..37a2967 100644 --- a/src/main/java/com/belellou/kevin/advent/year2015/Day1.java +++ b/src/main/java/com/belellou/kevin/advent/year2015/Day1.java @@ -10,7 +10,7 @@ import com.belellou.kevin.advent.generic.Year; @SuppressWarnings("unused") -public class Day1 extends AbstractDaySolver { +public class Day1 extends AbstractDaySolver { private static final int STARTING_FLOOR = 0; @@ -19,7 +19,7 @@ public Day1() { } @Override - protected int doSolveFirstStar(BufferedReader reader) throws IOException { + protected Integer doSolveFirstStar(BufferedReader reader) throws IOException { String line = reader.readLine(); int up = StringUtils.countMatches(line, "("); @@ -29,12 +29,12 @@ protected int doSolveFirstStar(BufferedReader reader) throws IOException { } @Override - public int getFirstStarSolution() { + public Integer getFirstStarSolution() { return 74; } @Override - protected int doSolveSecondStar(BufferedReader reader) throws IOException { + protected Integer doSolveSecondStar(BufferedReader reader) throws IOException { String line = reader.readLine(); int currentFloor = STARTING_FLOOR; @@ -56,7 +56,7 @@ protected int doSolveSecondStar(BufferedReader reader) throws IOException { } @Override - public int getSecondStarSolution() { + public Integer getSecondStarSolution() { return 1_795; } } diff --git a/src/main/java/com/belellou/kevin/advent/year2015/Day10.java b/src/main/java/com/belellou/kevin/advent/year2015/Day10.java index 48f7d11..75bf6cc 100644 --- a/src/main/java/com/belellou/kevin/advent/year2015/Day10.java +++ b/src/main/java/com/belellou/kevin/advent/year2015/Day10.java @@ -7,7 +7,7 @@ import com.belellou.kevin.advent.generic.Year; @SuppressWarnings("unused") -public class Day10 extends AbstractDaySolver { +public class Day10 extends AbstractDaySolver { public Day10() { super(Year.YEAR_2015, Day.DAY_10); @@ -34,7 +34,7 @@ private static String readLine(String line) { } @Override - protected int doSolveFirstStar(BufferedReader reader) { + protected Integer doSolveFirstStar(BufferedReader reader) { String line = reader.lines().findFirst().orElseThrow(); for (int i = 0; i < 40; i++) { @@ -45,12 +45,12 @@ protected int doSolveFirstStar(BufferedReader reader) { } @Override - public int getFirstStarSolution() { + public Integer getFirstStarSolution() { return 252_594; } @Override - protected int doSolveSecondStar(BufferedReader reader) { + protected Integer doSolveSecondStar(BufferedReader reader) { String line = reader.lines().findFirst().orElseThrow(); for (int i = 0; i < 50; i++) { @@ -61,7 +61,7 @@ protected int doSolveSecondStar(BufferedReader reader) { } @Override - public int getSecondStarSolution() { + public Integer getSecondStarSolution() { return 3_579_328; } } diff --git a/src/main/java/com/belellou/kevin/advent/year2015/Day11.java b/src/main/java/com/belellou/kevin/advent/year2015/Day11.java new file mode 100644 index 0000000..b3622ae --- /dev/null +++ b/src/main/java/com/belellou/kevin/advent/year2015/Day11.java @@ -0,0 +1,109 @@ +package com.belellou.kevin.advent.year2015; + +import java.io.BufferedReader; + +import com.belellou.kevin.advent.generic.AbstractDaySolver; +import com.belellou.kevin.advent.generic.Day; +import com.belellou.kevin.advent.generic.Year; + +@SuppressWarnings("unused") +public class Day11 extends AbstractDaySolver { + + public Day11() { + super(Year.YEAR_2015, Day.DAY_11); + } + + private static boolean isPasswordInvalid(String password) { + if (password.matches("^.*[iol].*$")) { + return true; + } + + boolean firstPairFound = false; + char firstPairChar = 0; + boolean secondPairFound = false; + + boolean straightFound = false; + + for (int i = 0; i < password.length() - 1; i++) { + char currentChar = password.charAt(i); + char nextChar = password.charAt(i + 1); + + if (nextChar == currentChar) { + if (!firstPairFound) { + firstPairFound = true; + firstPairChar = currentChar; + } else if (nextChar != firstPairChar) { + secondPairFound = true; + } + } else if (nextChar == currentChar + 1 && i < password.length() - 2) { + char nextNextChar = password.charAt(i + 2); + + if (nextNextChar == nextChar + 1) { + straightFound = true; + } + } + + if (firstPairFound && secondPairFound && straightFound) { + return false; + } + } + + return true; + } + + private static String incrementPassword(String password) { + StringBuilder newPassword = new StringBuilder(); + + boolean incrementNextChar = true; + + for (int i = password.length() - 1; i >= 0; i--) { + char currentChar = password.charAt(i); + + if (!incrementNextChar) { + newPassword.append(currentChar); + continue; + } + + if (currentChar == 'z') { + newPassword.append('a'); + } else { + newPassword.append((char) (currentChar + 1)); + incrementNextChar = false; + } + } + + return newPassword.reverse().toString(); + } + + @Override + protected String doSolveFirstStar(BufferedReader reader) { + String password = reader.lines().findFirst().orElseThrow(); + + do { + password = incrementPassword(password); + } while (isPasswordInvalid(password)); + + return password; + } + + @Override + public String getFirstStarSolution() { + return "vzbxxyzz"; + } + + @Override + protected String doSolveSecondStar(BufferedReader reader) { + String password = getFirstStarSolution(); + + do { + password = incrementPassword(password); + } while (isPasswordInvalid(password)); + + return password; + } + + @Override + public String getSecondStarSolution() { + return "vzcaabcc"; + } +} diff --git a/src/main/java/com/belellou/kevin/advent/year2015/Day2.java b/src/main/java/com/belellou/kevin/advent/year2015/Day2.java index 9edbd20..45297b4 100644 --- a/src/main/java/com/belellou/kevin/advent/year2015/Day2.java +++ b/src/main/java/com/belellou/kevin/advent/year2015/Day2.java @@ -12,7 +12,7 @@ import com.belellou.kevin.advent.generic.Year; @SuppressWarnings("unused") -public class Day2 extends AbstractDaySolver { +public class Day2 extends AbstractDaySolver { private static final Pattern PATTERN = Pattern.compile("^(\\d+)x(\\d+)x(\\d+)$"); @@ -52,22 +52,22 @@ private static Dimensions getDimensions(String line) { } @Override - protected int doSolveFirstStar(BufferedReader reader) { + protected Integer doSolveFirstStar(BufferedReader reader) { return reader.lines().map(Day2::findAreaNeeded).reduce(Integer::sum).orElseThrow(); } @Override - public int getFirstStarSolution() { + public Integer getFirstStarSolution() { return 1_588_178; } @Override - protected int doSolveSecondStar(BufferedReader reader) { + protected Integer doSolveSecondStar(BufferedReader reader) { return reader.lines().map(Day2::findLengthNeeded).reduce(Integer::sum).orElseThrow(); } @Override - public int getSecondStarSolution() { + public Integer getSecondStarSolution() { return 3_783_758; } diff --git a/src/main/java/com/belellou/kevin/advent/year2015/Day3.java b/src/main/java/com/belellou/kevin/advent/year2015/Day3.java index 598b3d4..a5dae62 100644 --- a/src/main/java/com/belellou/kevin/advent/year2015/Day3.java +++ b/src/main/java/com/belellou/kevin/advent/year2015/Day3.java @@ -10,14 +10,14 @@ import com.belellou.kevin.advent.generic.Year; @SuppressWarnings("unused") -public class Day3 extends AbstractDaySolver { +public class Day3 extends AbstractDaySolver { public Day3() { super(Year.YEAR_2015, Day.DAY_3); } @Override - protected int doSolveFirstStar(BufferedReader reader) throws IOException { + protected Integer doSolveFirstStar(BufferedReader reader) throws IOException { String line = reader.readLine(); int length = line.length(); @@ -49,12 +49,12 @@ protected int doSolveFirstStar(BufferedReader reader) throws IOException { } @Override - public int getFirstStarSolution() { + public Integer getFirstStarSolution() { return 2_081; } @Override - protected int doSolveSecondStar(BufferedReader reader) throws IOException { + protected Integer doSolveSecondStar(BufferedReader reader) throws IOException { String line = reader.readLine(); int length = line.length(); @@ -105,7 +105,7 @@ protected int doSolveSecondStar(BufferedReader reader) throws IOException { } @Override - public int getSecondStarSolution() { + public Integer getSecondStarSolution() { return 2_341; } diff --git a/src/main/java/com/belellou/kevin/advent/year2015/Day4.java b/src/main/java/com/belellou/kevin/advent/year2015/Day4.java index 76d7a7c..94112c8 100644 --- a/src/main/java/com/belellou/kevin/advent/year2015/Day4.java +++ b/src/main/java/com/belellou/kevin/advent/year2015/Day4.java @@ -11,7 +11,7 @@ import com.belellou.kevin.advent.generic.Year; @SuppressWarnings("unused") -public class Day4 extends AbstractDaySolver { +public class Day4 extends AbstractDaySolver { private static final String FIVE_ZEROES_PATTERN = "00000"; private static final String SIX_ZEROES_PATTERN = "000000"; @@ -31,26 +31,26 @@ private static int findNumber(String line, String pattern) { } @Override - protected int doSolveFirstStar(BufferedReader reader) throws IOException { + protected Integer doSolveFirstStar(BufferedReader reader) throws IOException { String line = reader.readLine(); return findNumber(line, FIVE_ZEROES_PATTERN); } @Override - public int getFirstStarSolution() { + public Integer getFirstStarSolution() { return 346_386; } @Override - protected int doSolveSecondStar(BufferedReader reader) throws IOException { + protected Integer doSolveSecondStar(BufferedReader reader) throws IOException { String line = reader.readLine(); return findNumber(line, SIX_ZEROES_PATTERN); } @Override - public int getSecondStarSolution() { + public Integer getSecondStarSolution() { return 9_958_218; } } diff --git a/src/main/java/com/belellou/kevin/advent/year2015/Day5.java b/src/main/java/com/belellou/kevin/advent/year2015/Day5.java index 09181f6..44b1d8e 100644 --- a/src/main/java/com/belellou/kevin/advent/year2015/Day5.java +++ b/src/main/java/com/belellou/kevin/advent/year2015/Day5.java @@ -9,7 +9,7 @@ import com.belellou.kevin.advent.generic.Year; @SuppressWarnings("unused") -public class Day5 extends AbstractDaySolver { +public class Day5 extends AbstractDaySolver { public Day5() { super(Year.YEAR_2015, Day.DAY_5); @@ -85,22 +85,22 @@ private static boolean secondStarStringTest(String string) { } @Override - protected int doSolveFirstStar(BufferedReader reader) { + protected Integer doSolveFirstStar(BufferedReader reader) { return reader.lines().filter(Day5::firstStarStringTest).toList().size(); } @Override - public int getFirstStarSolution() { + public Integer getFirstStarSolution() { return 255; } @Override - protected int doSolveSecondStar(BufferedReader reader) { + protected Integer doSolveSecondStar(BufferedReader reader) { return reader.lines().filter(Day5::secondStarStringTest).toList().size(); } @Override - public int getSecondStarSolution() { + public Integer getSecondStarSolution() { return 55; } } diff --git a/src/main/java/com/belellou/kevin/advent/year2015/Day6.java b/src/main/java/com/belellou/kevin/advent/year2015/Day6.java index 367817f..cba7fa3 100644 --- a/src/main/java/com/belellou/kevin/advent/year2015/Day6.java +++ b/src/main/java/com/belellou/kevin/advent/year2015/Day6.java @@ -10,7 +10,7 @@ import com.belellou.kevin.advent.generic.Year; @SuppressWarnings("unused") -public class Day6 extends AbstractDaySolver { +public class Day6 extends AbstractDaySolver { private static final String GROUP_COMMAND = "command"; private static final String GROUP_X0 = "x0"; @@ -70,7 +70,7 @@ private static void brightLights(int[][] lights, Instruction instruction, boolea } @Override - protected int doSolveFirstStar(BufferedReader reader) { + protected Integer doSolveFirstStar(BufferedReader reader) { Boolean[][] lights = new Boolean[1000][1000]; Arrays.stream(lights).forEach(booleans -> Arrays.fill(booleans, false)); @@ -91,12 +91,12 @@ protected int doSolveFirstStar(BufferedReader reader) { } @Override - public int getFirstStarSolution() { + public Integer getFirstStarSolution() { return 569_999; } @Override - protected int doSolveSecondStar(BufferedReader reader) { + protected Integer doSolveSecondStar(BufferedReader reader) { int[][] lights = new int[1000][1000]; reader.lines() @@ -115,7 +115,7 @@ protected int doSolveSecondStar(BufferedReader reader) { } @Override - public int getSecondStarSolution() { + public Integer getSecondStarSolution() { return 17_836_115; } diff --git a/src/main/java/com/belellou/kevin/advent/year2015/Day7.java b/src/main/java/com/belellou/kevin/advent/year2015/Day7.java index 42e512d..906abd9 100644 --- a/src/main/java/com/belellou/kevin/advent/year2015/Day7.java +++ b/src/main/java/com/belellou/kevin/advent/year2015/Day7.java @@ -18,7 +18,7 @@ import com.belellou.kevin.advent.generic.Year; @SuppressWarnings("unused") -public class Day7 extends AbstractDaySolver { +public class Day7 extends AbstractDaySolver { private static final String GROUP_FIRST_OPERAND = "firstOperand"; private static final String GROUP_SECOND_OPERAND = "secondOperand"; @@ -193,7 +193,7 @@ private static void computeGraph(SimpleDirectedGraph graph, } @Override - protected int doSolveFirstStar(BufferedReader reader) { + protected Integer doSolveFirstStar(BufferedReader reader) { SimpleDirectedGraph graph = new SimpleDirectedGraph<>(CustomEdge.class); reader.lines().forEach(line -> fillGraph(graph, line)); @@ -206,12 +206,12 @@ protected int doSolveFirstStar(BufferedReader reader) { } @Override - public int getFirstStarSolution() { + public Integer getFirstStarSolution() { return 16_076; } @Override - protected int doSolveSecondStar(BufferedReader reader) { + protected Integer doSolveSecondStar(BufferedReader reader) { SimpleDirectedGraph graph = new SimpleDirectedGraph<>(CustomEdge.class); reader.lines().forEach(line -> fillGraph(graph, line)); @@ -232,7 +232,7 @@ protected int doSolveSecondStar(BufferedReader reader) { } @Override - public int getSecondStarSolution() { + public Integer getSecondStarSolution() { return 2_797; } diff --git a/src/main/java/com/belellou/kevin/advent/year2015/Day8.java b/src/main/java/com/belellou/kevin/advent/year2015/Day8.java index 37d6ca8..ace0b24 100644 --- a/src/main/java/com/belellou/kevin/advent/year2015/Day8.java +++ b/src/main/java/com/belellou/kevin/advent/year2015/Day8.java @@ -13,7 +13,7 @@ import com.belellou.kevin.advent.generic.Year; @SuppressWarnings("unused") -public class Day8 extends AbstractDaySolver { +public class Day8 extends AbstractDaySolver { private static final Pattern PATTERN_HEXA = Pattern.compile("\\\\x[a-f0-9]{2}"); private static final Pattern PATTERN_QUOTE = Pattern.compile("\\\\\""); @@ -90,7 +90,7 @@ private static int countMemoryLength(String line) { } @Override - protected int doSolveFirstStar(BufferedReader reader) { + protected Integer doSolveFirstStar(BufferedReader reader) { List lines = reader.lines().toList(); int totalCodeLength = lines.stream().map(String::length).reduce(Integer::sum).orElseThrow(); @@ -117,18 +117,18 @@ protected int doSolveFirstStar(BufferedReader reader) { } @Override - public int getFirstStarSolution() { + public Integer getFirstStarSolution() { return 1350; } @Override - protected int doSolveSecondStar(BufferedReader reader) { + protected Integer doSolveSecondStar(BufferedReader reader) { return 0; } @DisableTest @Override - public int getSecondStarSolution() { + public Integer getSecondStarSolution() { return 0; } } diff --git a/src/main/java/com/belellou/kevin/advent/year2015/Day9.java b/src/main/java/com/belellou/kevin/advent/year2015/Day9.java index 8d5313a..775adc1 100644 --- a/src/main/java/com/belellou/kevin/advent/year2015/Day9.java +++ b/src/main/java/com/belellou/kevin/advent/year2015/Day9.java @@ -18,7 +18,7 @@ import com.belellou.kevin.advent.generic.Year; @SuppressWarnings("unused") -public class Day9 extends AbstractDaySolver { +public class Day9 extends AbstractDaySolver { private static final String GROUP_FIRST_LOCATION = "firstLocation"; private static final String GROUP_SECOND_LOCATION = "secondLocation"; @@ -37,7 +37,7 @@ public Day9() { } @Override - protected int doSolveFirstStar(BufferedReader reader) { + protected Integer doSolveFirstStar(BufferedReader reader) { SimpleWeightedGraph graph = new SimpleWeightedGraph<>(DefaultWeightedEdge.class); reader.lines().forEach(line -> { @@ -87,18 +87,18 @@ protected int doSolveFirstStar(BufferedReader reader) { @DisableTest @Override - public int getFirstStarSolution() { + public Integer getFirstStarSolution() { return 0; } @Override - protected int doSolveSecondStar(BufferedReader reader) { + protected Integer doSolveSecondStar(BufferedReader reader) { return 0; } @DisableTest @Override - public int getSecondStarSolution() { + public Integer getSecondStarSolution() { return 0; } } diff --git a/src/main/resources/2015/11/input.txt b/src/main/resources/2015/11/input.txt new file mode 100644 index 0000000..988745d --- /dev/null +++ b/src/main/resources/2015/11/input.txt @@ -0,0 +1 @@ +vzbxkghb diff --git a/src/test/java/com/belellou/kevin/advent/DaySolverTest.java b/src/test/java/com/belellou/kevin/advent/DaySolverTest.java index c29a135..ff2f0a1 100644 --- a/src/test/java/com/belellou/kevin/advent/DaySolverTest.java +++ b/src/test/java/com/belellou/kevin/advent/DaySolverTest.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; -import java.util.function.IntSupplier; +import java.util.function.Supplier; import com.pivovarit.function.ThrowingFunction; import org.junit.jupiter.api.Assumptions; @@ -32,7 +32,7 @@ public class DaySolverTest { private static void createDynamicTest(Class clazz, Consumer consumer) { try { - DaySolver daySolver = clazz.asSubclass(DaySolver.class).getDeclaredConstructor().newInstance(); + DaySolver daySolver = clazz.asSubclass(DaySolver.class).getDeclaredConstructor().newInstance(); boolean firstTestEnabled = !clazz.getMethod(METHOD_GET_FIRST_STAR_SOLUTION) .isAnnotationPresent(DisableTest.class); boolean secondTestEnabled = !clazz.getMethod(METHOD_GET_SECOND_STAR_SOLUTION) @@ -46,7 +46,7 @@ private static void createDynamicTest(Class clazz, Consumer cons } } - private static DynamicTest dynamicTestOf(DaySolver daySolver, boolean firstSolution, boolean enabled) { + private static DynamicTest dynamicTestOf(DaySolver daySolver, boolean firstSolution, boolean enabled) { return DynamicTest.dynamicTest(daySolver + (firstSolution ? FIRST_SOLUTION : SECOND_SOLUTION), firstSolution ? () -> doTest(enabled, daySolver::solveFirstStar, @@ -57,9 +57,9 @@ private static DynamicTest dynamicTestOf(DaySolver daySolver, boolean firstSolut ); } - private static void doTest(boolean enabled, IntSupplier method, IntSupplier result) { + private static void doTest(boolean enabled, Supplier method, Supplier result) { Assumptions.assumeTrue(enabled, MESSAGE_TEST_DISABLED); - assertThat(method.getAsInt()).isEqualTo(result.getAsInt()); + assertThat(method.get()).isEqualTo(result.get()); } @TestFactory