Skip to content

Instantly share code, notes, and snippets.

@blast-hardcheese
Created February 25, 2013 06:30
Show Gist options
  • Save blast-hardcheese/5028140 to your computer and use it in GitHub Desktop.
Save blast-hardcheese/5028140 to your computer and use it in GitHub Desktop.
Rewriting this to solve PythonChallenge level 23. It works, but it's not very readable. Suggestions welcome.
val map = {
type Dict = Map[Char, Char]
val initial = Map[Char, Char]()
(for(c <- List('A', 'a'); i <- 0 until 26) yield {
((i + c).toChar, ((i + 13) % 26 + c).toChar)
}).foldLeft[Dict](initial)({ (map, kv) =>
val (k, v) = kv
map.updated(k, v)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment