Skip to content

Instantly share code, notes, and snippets.

@nhosoya
Created June 18, 2020 04:04
Show Gist options
  • Select an option

  • Save nhosoya/6b23d0a3272f12128706e3a560ab2721 to your computer and use it in GitHub Desktop.

Select an option

Save nhosoya/6b23d0a3272f12128706e3a560ab2721 to your computer and use it in GitHub Desktop.
l = ("a".."z").to_a
h = ("A".."Z").to_a
target = "abcAbc"
target.chars.map do |c|
if l.index(c)
l[(l.index(c) + 13) % 26]
elsif h.index(c)
h[(h.index(c) + 13) % 26]
else
c
end
end.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment