@@ -18,8 +18,8 @@ val PAD_LAYOUTS = Map(
18
18
(PadType .Num , Map (
19
19
(Vec2 (0 , 0 ), '1' ), (Vec2 (1 , 0 ), '2' ), (Vec2 (2 , 0 ), '3' ),
20
20
(Vec2 (0 , 1 ), '4' ), (Vec2 (1 , 1 ), '5' ), (Vec2 (2 , 1 ), '6' ),
21
- (Vec2 (0 , 2 ), '7' ), (Vec2 (1 , 2 ), '7 ' ), (Vec2 (2 , 2 ), '8 ' ),
22
- (Vec2 (1 , 3 ), '9 ' ), (Vec2 (2 , 3 ), 'A' ),
21
+ (Vec2 (0 , 2 ), '7' ), (Vec2 (1 , 2 ), '8 ' ), (Vec2 (2 , 2 ), '9 ' ),
22
+ (Vec2 (1 , 3 ), '0 ' ), (Vec2 (2 , 3 ), 'A' ),
23
23
)),
24
24
(PadType .Dir , Map (
25
25
(Vec2 (1 , 0 ), '^' ), (Vec2 (2 , 0 ), 'A' ),
@@ -73,7 +73,7 @@ case class State(pads: List[Pad] = List(), output: String = "") {
73
73
}
74
74
75
75
case class Node (state : State = State (), program : String = " " ) extends Ordered [Node ] {
76
- def compare (that : Node ): Int = program.length() compare that. program.length()
76
+ def compare (that : Node ): Int = that. program.length() compare program.length() // Intentionally reversed for min-heap
77
77
}
78
78
79
79
def shortestProgram (startState : State , goal : String ): String =
@@ -88,7 +88,6 @@ def shortestProgram(startState: State, goal: String): String =
88
88
89
89
while ! queue.isEmpty do
90
90
val node = queue.dequeue()
91
- println(node)
92
91
if node.state.output == goal then
93
92
return node.program
94
93
0 commit comments