Created
January 23, 2012 20:32
-
-
Save mkulak/1665398 to your computer and use it in GitHub Desktop.
Darkus january '12 programming contest solution
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
def decode(key: Seq[Char], bytes: Array[Byte]): String = new String(bytes.indices.map(i => bytes(i) ^ key(i % key.length)).map(_.toByte).toArray, "latin1") | |
val bytes = Source.fromFile("Code.hs.enc", "latin1").mkString.getBytes("latin1") | |
val res = bytes.sliding(5, 1).map(decode("impor", _)).filter(decode(_, bytes).contains("main")).toList.headOption.map(decode(_, bytes)) | |
println(res.getOrElse("Solution not found")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment