diff --git a/src/Day01.java b/src/Day01.java index d9cf529..bd7f8ff 100644 --- a/src/Day01.java +++ b/src/Day01.java @@ -16,11 +16,12 @@ public class Day01 { while (scanner.hasNextLine()) { String instruction = scanner.nextLine(); int change = Integer.parseInt(instruction.substring(1)); - dial = switch (instruction.charAt(0)) { - case 'L' -> (dial - change) % 100; - case 'R' -> (dial + change) % 100; - default -> dial; // impossible + int step = switch (instruction.charAt(0)) { + case 'L' -> -1; + case 'R' -> 1; + default -> 0; // impossible }; + dial = (dial + change * step) % 100; if (dial == 0) { password += 1; }