Skip to content

Commit 820f629

Browse files
committed
more cleanup, comments
1 parent fd4cdd0 commit 820f629

File tree

4 files changed

+6
-14
lines changed

4 files changed

+6
-14
lines changed

src/main/java/com/codefork/aoc2024/day21/Keypad.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class Keypad {
1717
new Button(">", new Position(2, 1))
1818
);
1919

20-
// directional keypad: this is used by both navigator
20+
// directional keypad: this is used by both navigators
2121
public static final Keypad dirKeypad = new Keypad(dirKeypadButtons);
2222

2323
private final List<Button> buttons;
@@ -65,7 +65,7 @@ private Map<Move, List<String>> createShortestPaths() {
6565
var shortestPaths = ShortestPaths.create(buttons, graph, button1);
6666
var otherButtons = buttons.stream().filter(b -> !b.equals(button1)).toList();
6767
for (var button2 : otherButtons) {
68-
var presses = shortestPaths.getPossiblePressSequences(button2);
68+
var presses = shortestPaths.getPathsAsStrings(button2);
6969
//System.out.println("move " + button1 + "->" + button2 + " adding presses=" + presses);
7070
result.put(new Move(button1, button2), presses);
7171
}
@@ -79,10 +79,6 @@ private Map<Move, List<String>> createShortestPaths() {
7979
return result;
8080
}
8181

82-
public Map<String, Button> getButtonsMap() {
83-
return buttonsMap;
84-
}
85-
8682
public Button getButton(String symbol) {
8783
return buttonsMap.get(symbol);
8884
}

src/main/java/com/codefork/aoc2024/day21/Part01.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@
33
import com.codefork.aoc2024.Problem;
44
import com.codefork.aoc2024.util.Assert;
55

6-
import java.util.ArrayList;
7-
import java.util.HashSet;
8-
import java.util.Set;
96
import java.util.stream.Stream;
107

11-
import static com.codefork.aoc2024.day21.ShipLock.getNumericPortion;
12-
138
public class Part01 extends Problem {
149

1510
public String solve(Stream<String> data) {

src/main/java/com/codefork/aoc2024/day21/PressSequence.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
/**
77
* Represents a sequence of button actions to perform.
8-
* Order doesn't actually matter in a press sequence, only the moves do.
8+
* Order doesn't actually matter in a press sequence, only the moves do,
9+
* so we use a Map of Moves to their counts
910
*/
1011
public record PressSequence(Map<Move, Long> moves) {
1112

src/main/java/com/codefork/aoc2024/day21/ShortestPaths.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ public List<List<Button>> getPaths(Button target) {
8989

9090
/**
9191
* turns a path (list of Buttons from source to target) into a list of the directional
92-
* symbol sequences needed to get from source to target. This is probably not be represented
92+
* symbol sequences needed to get from source to target. This is probably not best represented
9393
* as a String, but that's how I implemented it early on and I didn't want to refactor it.
9494
*/
95-
public List<String> getPossiblePressSequences(Button target) {
95+
public List<String> getPathsAsStrings(Button target) {
9696
var paths = getPaths(target);
9797
return paths.stream()
9898
.map(path ->

0 commit comments

Comments
 (0)