Added placeholder days

This commit is contained in:
Sugui 2023-12-02 08:52:52 +01:00
parent 3a7e2e235b
commit 12c4195525
4 changed files with 74 additions and 8 deletions

View File

@ -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<String, List<String>> 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);
}
}

View File

@ -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";
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}