We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d6e43d1 commit e8d3bcfCopy full SHA for e8d3bcf
day21/src/day21.scala
@@ -27,6 +27,10 @@ val PAD_LAYOUTS = Map(
27
)),
28
)
29
30
+extension (ptype: PadType) {
31
+ def locate(c: Char) = PAD_LAYOUTS(ptype).find(_._2 == c).get._1
32
+}
33
+
34
val DIRECTIONS = Map(
35
('<', Vec2(-1, 0)),
36
('>', Vec2( 1, 0)),
@@ -50,7 +54,7 @@ case class Pad(ptype: PadType, pos: Vec2) {
50
54
}
51
55
52
56
object Pad {
53
- def apply(ptype: PadType): Pad = Pad(ptype, PAD_LAYOUTS(ptype).find(_._2 == 'A').get._1)
57
+ def apply(ptype: PadType): Pad = Pad(ptype, ptype.locate('A'))
58
59
60
case class State(pads: List[Pad] = List(), output: String = "") {
0 commit comments