We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def cypher(k):
def mapper(c):
if not c.isalpha():
return c
n_letters = 26
a = ord('A') if c.isupper() else ord('a')
c = ord(c)
new_c = ((c - a + k) % n_letters) + a
return chr(new_c)
return mapper
def caesarCipher(s, k):
return "".join(map(cypher(k), [x for x in s]))
k):
# Write your code here
return "".join(map(cypher(k), [x for x in s])
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
k): # Write your code here return "".join(map(cypher(k), [x for x in s])