-
-
Save waynejo/bc79665297e15871b1c208d25da28d1b to your computer and use it in GitHub Desktop.
You Can Go Your Own Way.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileInputStream | |
import scala.io.StdIn | |
object Solution extends App { | |
Console.setIn(new FileInputStream("example.in")) | |
def solve(mazeSize: Int, preventedPath: String): String = { | |
preventedPath.map { | |
case 'E' => 'S' | |
case _ => 'E' | |
} | |
} | |
val cases = StdIn.readLine().toInt | |
(1 to cases) foreach { i => { | |
val mazeSize = StdIn.readLine().toInt | |
val preventedPath = StdIn.readLine() | |
val answer = solve(mazeSize, preventedPath) | |
println(s"Case #$i: $answer") | |
}} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment