Skip to content

Commit b88b1b3

Browse files
committed
D10: Added opposite to Direction enum.
1 parent a3f2c02 commit b88b1b3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/kotlin/common/intpos2d/intpos2d.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,11 @@ enum class Direction(val delta: IntPos2D) {
3636
SOUTH -> EAST
3737
EAST -> NORTH
3838
}
39+
40+
fun opposite(): Direction = when (this) {
41+
NORTH -> SOUTH
42+
EAST -> WEST
43+
SOUTH -> NORTH
44+
WEST -> EAST
45+
}
3946
}

0 commit comments

Comments
 (0)