Skip to content

Instantly share code, notes, and snippets.

@mkulak
Created January 23, 2012 20:32
Show Gist options
  • Save mkulak/1665398 to your computer and use it in GitHub Desktop.
Save mkulak/1665398 to your computer and use it in GitHub Desktop.
Darkus january '12 programming contest solution
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