File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed
Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -18,22 +18,22 @@ extension (x: Int) inline def ±(y: Int) = x - y to x + y
1818extension (x : Inclusive )
1919 inline def & (y : Inclusive ) = (x.start max y.start) to (x.end min y.end)
2020
21- opaque type Pos = ( Int , Int )
21+ opaque type Pos = Int
2222
2323object Pos :
24- val up : Pos = (0 , - 1 )
25- val down : Pos = (0 , 1 )
26- val left : Pos = (- 1 , 0 )
27- val right : Pos = (1 , 0 )
28- val zero : Pos = (0 , 0 )
29- def apply (x : Int , y : Int ): Pos = (x, y)
24+ val up = Pos (0 , - 1 )
25+ val down = Pos (0 , 1 )
26+ val left = Pos (- 1 , 0 )
27+ val right = Pos (1 , 0 )
28+ val zero = Pos (0 , 0 )
29+ inline def apply (x : Int , y : Int ): Pos = y << 16 | x
3030
3131 extension (p : Pos )
32- inline def x = p._1
33- inline def y = p._2
32+ inline def x = p & 0xffff
33+ inline def y = p >> 16
3434 inline def neighbors : List [Pos ] =
3535 List (p + up, p + right, p + down, p + left)
36- inline def + (q : Pos ): Pos = (p.x + q.x, p.y + q.y)
36+ inline def + (q : Pos ): Pos = Pos (p.x + q.x, p.y + q.y)
3737 inline infix def taxiDist (q : Pos ) = (p.x - q.x).abs + (p.y - q.y).abs
3838
3939case class Rect (x : Inclusive , y : Inclusive ):
You can’t perform that action at this time.
0 commit comments