You are viewing a single comment's thread. Return to all comments →
def rot13(secret_messages)
return secret_messages.map {|d| ans = "" for i in(0...d.length) ans.insert(i,helper(d[i])) end ans }
end
def helper(ch) alpb = "abcdefghijklmnopqrstuvwxyz" i = ch.downcase.ord - 'a'.ord return i > 25 || i < 0 ? ch : ch.ord >= 65 && ch.ord <=90 ? alpb[(i + 13)%26].upcase : alpb[(i + 13)%26] end
Seems like cookies are disabled on this browser, please enable them to open this website
Ruby - Enumerable - collect
You are viewing a single comment's thread. Return to all comments →
def rot13(secret_messages)
end
def helper(ch) alpb = "abcdefghijklmnopqrstuvwxyz" i = ch.downcase.ord - 'a'.ord return i > 25 || i < 0 ? ch : ch.ord >= 65 && ch.ord <=90 ? alpb[(i + 13)%26].upcase : alpb[(i + 13)%26] end