|
1 | 1 | package com.codefork.aoc2024.day21;
|
2 | 2 |
|
3 |
| -import java.util.ArrayList; |
4 | 3 | import java.util.HashMap;
|
5 |
| -import java.util.List; |
6 | 4 | import java.util.Map;
|
7 | 5 |
|
8 | 6 | /**
|
@@ -34,53 +32,6 @@ public static PressSequence create(Keypad keypad, String seq) {
|
34 | 32 | return new PressSequence(moves);
|
35 | 33 | }
|
36 | 34 |
|
37 |
| -// /** |
38 |
| -// * returns list of new PressSequences that are the possibilities that can result from adding the passed-in move |
39 |
| -// * |
40 |
| -// * @param keypad used to get the Button objects for the symbols, and to get the possible paths between buttons. |
41 |
| -// */ |
42 |
| -// public List<PressSequence> addMove(Keypad keypad, Move move, long multiplier) { |
43 |
| -// var results = new ArrayList<PressSequence>(); |
44 |
| -// var paths = keypad.getMovesToPaths().get(move); |
45 |
| -// |
46 |
| -// //System.out.println("from=" + _from + " to=" + _to + " paths=" + paths); |
47 |
| -// |
48 |
| -// for (var path : paths) { |
49 |
| -// var copy = copy(); |
50 |
| -// |
51 |
| -// char first = path.charAt(0); |
52 |
| -// |
53 |
| -// // note that we use dirKeypad here, since movements match up with the directional keypad |
54 |
| -// |
55 |
| -// // add a transitional move from the last implicit "A" |
56 |
| -// if (path.length() > 1 && first != 'A') { |
57 |
| -// var transition = new Move(Keypad.dirKeypad.getButton("A"), Keypad.dirKeypad.getButton(first)); |
58 |
| -// copy.moves().merge(transition, multiplier, Long::sum); |
59 |
| -// } |
60 |
| -// |
61 |
| -// var from = first; |
62 |
| -// for (var i = 1; i < path.length(); i++) { |
63 |
| -// var to = path.charAt(i); |
64 |
| -// |
65 |
| -// var moveInPath = new Move(Keypad.dirKeypad.getButton(from), Keypad.dirKeypad.getButton(to)); |
66 |
| -// copy.moves().merge(moveInPath, multiplier, Long::sum); |
67 |
| -// |
68 |
| -// from = to; |
69 |
| -// } |
70 |
| -// |
71 |
| -// // this happens when a button repeats (i.e. moves from a button to itself) |
72 |
| -// if (path.length() == 1) { |
73 |
| -// var aButton = Keypad.dirKeypad.getButton("A"); |
74 |
| -// var moveInPath = new Move(aButton, aButton); |
75 |
| -// copy.moves().merge(moveInPath, multiplier, Long::sum); |
76 |
| -// } |
77 |
| -// results.add(copy); |
78 |
| -// } |
79 |
| -// //System.out.println("addMove returning=" + results); |
80 |
| -// |
81 |
| -// return results; |
82 |
| -// } |
83 |
| -// |
84 | 35 | public PressSequence copy() {
|
85 | 36 | return new PressSequence(new HashMap<>(moves));
|
86 | 37 | }
|
|
0 commit comments