Skip to content

Commit

Permalink
Add solution for rot13
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigmanificient committed Nov 13, 2024
1 parent 80d59c7 commit a08ffa5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/python/katas/py5kyu/rot13.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Kata url: https://www.codewars.com/kata/52223df9e8f98c7aa7000062."""

from string import ascii_lowercase

def _rot13_char(c):
p = ascii_lowercase.find(c.lower())
if p == -1:
return c

l = ascii_lowercase[(p + 13) % len(ascii_lowercase)]
return l if c.islower() else l.upper()


def rot13(message):
return ''.join(map(_rot13_char, message))

0 comments on commit a08ffa5

Please sign in to comment.