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:
parent
98c91a107a
commit
c57ed4e3d5
2 changed files with 5 additions and 5 deletions
|
|
@ -13,9 +13,9 @@ class Rover {
|
||||||
fun go(cms: String) {
|
fun go(cms: String) {
|
||||||
for (c in cms) {
|
for (c in cms) {
|
||||||
when (c) {
|
when (c) {
|
||||||
'L' -> { when (rs.dd) { 'E' -> rs.dd = 'N' 'N' -> rs.dd = 'W' 'W' -> rs.dd = 'S' 'S' -> rs.dd = 'E'}}
|
'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'}}
|
'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++}}
|
'M' -> { when (rs.dd) { 'E' -> rs.xx++ 'S' -> rs.yy-- 'W' -> rs.xx-- 'N' -> rs.yy++ } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ class MarsRoverTests {
|
||||||
"1 2 S, M, 1 1 S",
|
"1 2 S, M, 1 1 S",
|
||||||
"1 2 W, M, 0 2 W",
|
"1 2 W, M, 0 2 W",
|
||||||
"1 2 N, LMLMLMLMM, 1 3 N",
|
"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) {
|
fun `execute commands`(startingPosition: String, instructions: String, expectedOutput: String) {
|
||||||
val rover = Rover(startingPosition)
|
val rover = Rover(startingPosition)
|
||||||
rover.go(instructions)
|
rover.go(instructions)
|
||||||
assertEquals(expectedOutput, rover.pos())
|
assertEquals(expectedOutput, rover.pos())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue