Created
September 4, 2015 12:03
-
-
Save parkey19/0635488edd4abd030409 to your computer and use it in GitHub Desktop.
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.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