Skip to content

Instantly share code, notes, and snippets.

@olbrichj
Last active May 3, 2018 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olbrichj/6ff2c87e0b1689baa246f21b0f54a9b1 to your computer and use it in GitHub Desktop.
Save olbrichj/6ff2c87e0b1689baa246f21b0f54a9b1 to your computer and use it in GitHub Desktop.
func rotFinal(msg: String, key: String, op: (UInt32, UInt32) -> UInt32) -> String {
return String(zip(msg.unicodeScalars.map{$0.value}, String(repeating: key, count: (msg.count / key.count) + 1)
.unicodeScalars.map{$0.value})
.map{Character(UnicodeScalar(op($0.0, $0.1))!)})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment