You are viewing a single comment's thread. Return to all comments →
def caesarCipher(s, k): res="" for i in range(len(s)): small, ch = check('a','z', s, i, k) if not small: big, ch = check('A', 'Z', s, i, k) res+=ch return res def check(start, end, s, i, k): n = ord(end)-ord(start)+1 ch = s[i] if ord(start) <= ord(ch) <= ord(end): i = ord(ch) - ord(start) new_i = (i + k) % n return True, chr(ord(start) + new_i) return False, ch
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 →