From 12c41955253bb3257f8eabb8aee1bdf7f38e8875 Mon Sep 17 00:00:00 2001 From: Sugui Date: Sat, 2 Dec 2023 08:52:52 +0100 Subject: [PATCH] Added placeholder days --- src/main/java/sugui/Day01.java | 9 ++++---- src/main/java/sugui/DayXX.java | 31 +++++++++++++++++++++++++++ src/test/java/sugui/Day01Test.java | 8 +++---- src/test/java/sugui/DayXXTest.java | 34 ++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 src/main/java/sugui/DayXX.java create mode 100644 src/test/java/sugui/DayXXTest.java diff --git a/src/main/java/sugui/Day01.java b/src/main/java/sugui/Day01.java index 0705034..bbe366b 100644 --- a/src/main/java/sugui/Day01.java +++ b/src/main/java/sugui/Day01.java @@ -13,6 +13,7 @@ import java.util.Map; import java.util.function.IntPredicate; public class Day01 { + public static Path inputPath = Paths.get("resources/input01.txt"); public static Map> spelledDigitsMap = Map.of( @@ -34,7 +35,7 @@ public class Day01 { System.out.println("Second result: " + secondResult); } - public static int getFirstPuzzleResult(String input) throws IOException { + public static String getFirstPuzzleResult(String input) { IntPredicate isDigit = c -> Character.isDigit(c); var bufferedReader = new BufferedReader(new StringReader(input)); var result = bufferedReader.lines() @@ -53,10 +54,10 @@ public class Day01 { return number; }) .reduce(0, (a, b) -> a + b); - return result; + return Integer.toString(result); } - public static int getSecondPuzzleResult(String input) throws IOException { + public static String getSecondPuzzleResult(String input) { var bufferedReader = new BufferedReader(new StringReader(input)); var result = bufferedReader.lines() .map(line -> { @@ -77,6 +78,6 @@ public class Day01 { int number = Integer.parseInt(positions.get(minPosition) + positions.get(maxPosition)); return number; }).reduce(0, (a, b) -> a + b); - return result; + return Integer.toString(result); } } diff --git a/src/main/java/sugui/DayXX.java b/src/main/java/sugui/DayXX.java new file mode 100644 index 0000000..4477b8a --- /dev/null +++ b/src/main/java/sugui/DayXX.java @@ -0,0 +1,31 @@ +package sugui; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class DayXX { + + public static Path inputPath = Paths.get("resources/inputXX.txt"); + + // Other static variables needed to solve the problem... + + public static void main(String[] args) throws IOException { + var input = Files.readString(inputPath); + var firstResult = getFirstPuzzleResult(input); + var secondResult = getSecondPuzzleResult(input); + System.out.println("First result: " + firstResult); + System.out.println("Second result: " + secondResult); + } + + public static String getFirstPuzzleResult(String input) { + // Here goes the code for the solution to the first problem... + return "Solution to the first problem"; + } + + public static String getSecondPuzzleResult(String input) { + // Here goes the code for the solution to the second problem... + return "Solution to the second problem"; + } +} diff --git a/src/test/java/sugui/Day01Test.java b/src/test/java/sugui/Day01Test.java index 9cdfecf..e00aeb8 100644 --- a/src/test/java/sugui/Day01Test.java +++ b/src/test/java/sugui/Day01Test.java @@ -25,18 +25,18 @@ public class Day01Test { zoneight234 7pqrstsixteen """; - public static int firstBasicResult = 142; - public static int secondBasicResult = 281; + public static String firstBasicResult = "142"; + public static String secondBasicResult = "281"; @Test public void firstBasicCase() throws IOException { - int actualResult = Day01.getFirstPuzzleResult(firstBasicInput); + String actualResult = Day01.getFirstPuzzleResult(firstBasicInput); assertEquals(firstBasicResult, actualResult); } @Test public void secondBasicCase() throws IOException { - int actualResult = Day01.getSecondPuzzleResult(secondBasicInput); + String actualResult = Day01.getSecondPuzzleResult(secondBasicInput); assertEquals(secondBasicResult, actualResult); } } diff --git a/src/test/java/sugui/DayXXTest.java b/src/test/java/sugui/DayXXTest.java new file mode 100644 index 0000000..2716410 --- /dev/null +++ b/src/test/java/sugui/DayXXTest.java @@ -0,0 +1,34 @@ +package sugui; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class DayXXTest { + + public static String firstBasicInput = """ + Basic input for the first problem + """; + public static String secondBasicInput = """ + Basic input for the second problem + """; + public static String firstBasicResult = "Solution to the first problem"; + public static String secondBasicResult = "Solution to the second problem"; + + @Test + public void firstBasicCase() throws IOException { + String actualResult = DayXX.getFirstPuzzleResult(firstBasicInput); + assertEquals(firstBasicResult, actualResult); + } + + @Test + public void secondBasicCase() throws IOException { + String actualResult = DayXX.getSecondPuzzleResult(secondBasicInput); + assertEquals(secondBasicResult, actualResult); + } +}