You are viewing a single comment's thread. Return to all comments →
Optimized!
from string import ascii_lowercase, ascii_uppercase import functools @functools.lru_cache(maxsize=26) def get_trans(k): return str.maketrans( ascii_lowercase + ascii_uppercase, ascii_lowercase[k:] + ascii_lowercase[:k] + ascii_uppercase[k:] + ascii_uppercase[:k] ) def caesarCipher(s, k): return s.translate(get_trans(k % 26))
Above code runs roughly 25 times faster than your code. ;)
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
Optimized!
Above code runs roughly 25 times faster than your code. ;)