Sha256: bee895a526f67d66b06b735207ed0197e9364bbdea5351638236c63f6ec1f17e

Contents?: true

Size: 527 Bytes

Versions: 396

Compression:

Stored size: 527 Bytes

Contents

from string import ascii_lowercase
import sys

if sys.version_info[0] == 2:
    from string import maketrans
else:
    maketrans = str.maketrans


BLKSZ = 5
trtbl = maketrans(ascii_lowercase, ascii_lowercase[::-1])


def base_trans(text):
    return ''.join([c for c in text if c.isalnum()]).lower().translate(trtbl)


def encode(plain):
    cipher = base_trans(plain)
    return " ".join([cipher[i:i + BLKSZ]
                     for i in range(0, len(cipher), BLKSZ)])


def decode(ciphered):
    return base_trans(ciphered)

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.179 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.178 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.177 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.176 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.175 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.174 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.173 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.172 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.171 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.170 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.169 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.167 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.166 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.165 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.164 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.163 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.162 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.161 tracks/python/exercises/atbash-cipher/example.py
trackler-2.2.1.160 tracks/python/exercises/atbash-cipher/example.py