use nextLine instead of a custom delimiter
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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' -> {
|
||||
|
||||
Reference in New Issue
Block a user