From 8830face193ecd60d930a60a58b6bbc1ea40711b Mon Sep 17 00:00:00 2001 From: David Ashby Date: Mon, 1 Dec 2025 21:20:27 -0500 Subject: [PATCH] make the two parts structurally similar --- src/Day01.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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; }