Skip to content

Instantly share code, notes, and snippets.

@parkey19
Created September 4, 2015 12:03
Show Gist options
  • Save parkey19/0635488edd4abd030409 to your computer and use it in GitHub Desktop.
Save parkey19/0635488edd4abd030409 to your computer and use it in GitHub Desktop.
import java.io.PrintStream
import scala.io.Source
object GoogleIo extends App {
val inFile = "A-small-practice.in"
val outFile = "A-small-practice.output"
Console.setIn(Source.fromFile(inFile).bufferedReader())
Console.setOut(new PrintStream(outFile))
val num = Console readInt()
for(i <- 1 to num ) {
val chars = Console readInt()
val line = Console readLine()
val result = (for(j <- 0 until line.length by 8) yield {
val char = line.substring(j , j + 8).map(_ match {
case 'I' => '1'
case 'O' => '0'
}
)
Integer.parseInt(char, 2).toChar
} ) mkString
Console println "Case #" + i + ": " + result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment