style: format code with Ktlint

This commit fixes the style issues introduced in 98c91a1 according to the output
from Ktlint.

Details: None
This commit is contained in:
deepsource-autofix[bot] 2025-10-14 18:43:05 +00:00 committed by GitHub
commit c57ed4e3d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -13,9 +13,9 @@ class Rover {
fun go(cms: String) {
for (c in cms) {
when (c) {
'L' -> { when (rs.dd) { 'E' -> rs.dd = 'N' 'N' -> rs.dd = 'W' 'W' -> rs.dd = 'S' 'S' -> rs.dd = 'E'}}
'R' -> { when (rs.dd) { 'E' -> rs.dd = 'S' 'S' -> rs.dd = 'W' 'W' -> rs.dd = 'N' 'N' -> rs.dd = 'E'}}
'M' -> { when (rs.dd) { 'E' -> rs.xx++ 'S' -> rs.yy-- 'W' -> rs.xx-- 'N' -> rs.yy++}}
'L' -> { when (rs.dd) { 'E' -> rs.dd = 'N' 'N' -> rs.dd = 'W' 'W' -> rs.dd = 'S' 'S' -> rs.dd = 'E' } }
'R' -> { when (rs.dd) { 'E' -> rs.dd = 'S' 'S' -> rs.dd = 'W' 'W' -> rs.dd = 'N' 'N' -> rs.dd = 'E' } }
'M' -> { when (rs.dd) { 'E' -> rs.xx++ 'S' -> rs.yy-- 'W' -> rs.xx-- 'N' -> rs.yy++ } }
}
}
}

View file

@ -20,11 +20,11 @@ class MarsRoverTests {
"1 2 S, M, 1 1 S",
"1 2 W, M, 0 2 W",
"1 2 N, LMLMLMLMM, 1 3 N",
"3 3 E, MMRMMRMRRM, 5 1 E"
"3 3 E, MMRMMRMRRM, 5 1 E",
)
fun `execute commands`(startingPosition: String, instructions: String, expectedOutput: String) {
val rover = Rover(startingPosition)
rover.go(instructions)
assertEquals(expectedOutput, rover.pos())
}
}
}