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

View File

@@ -10,11 +10,11 @@ public class Day01 {
} }
private static void part1() { 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 dial = 50;
int password = 0; int password = 0;
while (scanner.hasNext()) { while (scanner.hasNextLine()) {
String instruction = scanner.next(); String instruction = scanner.nextLine();
int change = Integer.parseInt(instruction.substring(1)); int change = Integer.parseInt(instruction.substring(1));
switch (instruction.charAt(0)) { switch (instruction.charAt(0)) {
case 'L' -> { case 'L' -> {
@@ -36,11 +36,11 @@ public class Day01 {
// this is the inefficient way to do it, but it's also accurate! // this is the inefficient way to do it, but it's also accurate!
private static void part2() { 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 dial = 50;
int password = 0; int password = 0;
while (scanner.hasNext()) { while (scanner.hasNextLine()) {
String instruction = scanner.next(); String instruction = scanner.nextLine();
int change = Integer.parseInt(instruction.substring(1)); int change = Integer.parseInt(instruction.substring(1));
switch (instruction.charAt(0)) { switch (instruction.charAt(0)) {
case 'L' -> { case 'L' -> {