Skip to content

Instantly share code, notes, and snippets.

@kp666
Created September 9, 2017 08:35
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 kp666/36b78de9f27c4adc795838f71f84fee3 to your computer and use it in GitHub Desktop.
Save kp666/36b78de9f27c4adc795838f71f84fee3 to your computer and use it in GitHub Desktop.
def all_alphabets
[[*'A'..'Z'], [*'a'..'z']]
end
def rotated_by_key(key)
all_alphabets.flat_map{|x|x.rotate(key)}
end
def ceaser(string,key)
string.tr(all_alphabets.join,rotated_by_key(key).join)
end
ceaser("This is my string",13)
ceaser("SDS Coding Challenge #3",20 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment