Skip to content

Instantly share code, notes, and snippets.

@waynejo
Created May 3, 2019 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waynejo/bc79665297e15871b1c208d25da28d1b to your computer and use it in GitHub Desktop.
Save waynejo/bc79665297e15871b1c208d25da28d1b to your computer and use it in GitHub Desktop.
You Can Go Your Own Way.scala
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