use nextLine instead of a custom delimiter

This commit is contained in:
2025-12-01 20:53:35 -05:00
parent 4f6d8e5525
commit 3dec978591
2 changed files with 12 additions and 12 deletions

View File

@@ -10,9 +10,9 @@ public class Day00 {
}
private static void part1() {
try (Scanner scanner = new Scanner(new FileReader("resources/inputs/00/input")).useDelimiter("\\R")) {
while (scanner.hasNext()) {
sb.append(scanner.next());
try (Scanner scanner = new Scanner(new FileReader("resources/inputs/00/input"))) {
while (scanner.hasNextLine()) {
sb.append(scanner.nextLine());
sb.append("\n");
}
String input = sb.toString();
@@ -23,9 +23,9 @@ public class Day00 {
}
private static void part2() {
try (Scanner scanner = new Scanner(new FileReader("resources/inputs/00/input")).useDelimiter("\\R")) {
while (scanner.hasNext()) {
sb.append(scanner.next());
try (Scanner scanner = new Scanner(new FileReader("resources/inputs/00/input"))) {
while (scanner.hasNextLine()) {
sb.append(scanner.nextLine());
sb.append("\n");
}
String input = sb.toString();

View File

@@ -10,11 +10,11 @@ public class Day01 {
}
private static void part1() {
try (Scanner scanner = new Scanner(new FileReader("resources/inputs/01/input")).useDelimiter("\\R")) {
try (Scanner scanner = new Scanner(new FileReader("resources/inputs/01/input"))) {
int dial = 50;
int password = 0;
while (scanner.hasNext()) {
String instruction = scanner.next();
while (scanner.hasNextLine()) {
String instruction = scanner.nextLine();
int change = Integer.parseInt(instruction.substring(1));
switch (instruction.charAt(0)) {
case 'L' -> {
@@ -36,11 +36,11 @@ public class Day01 {
// this is the inefficient way to do it, but it's also accurate!
private static void part2() {
try (Scanner scanner = new Scanner(new FileReader("resources/inputs/01/input")).useDelimiter("\\R")) {
try (Scanner scanner = new Scanner(new FileReader("resources/inputs/01/input"))) {
int dial = 50;
int password = 0;
while (scanner.hasNext()) {
String instruction = scanner.next();
while (scanner.hasNextLine()) {
String instruction = scanner.nextLine();
int change = Integer.parseInt(instruction.substring(1));
switch (instruction.charAt(0)) {
case 'L' -> {