Created
December 19, 2017 17:57
-
-
Save reikoNeko/efde43b7aa2e308c143ec62a800359ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cryptogram(plaintext): | |
from random import shuffle | |
# create cryptogram cypher. You can't shuffle strings, so lists it is. | |
alpha = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') | |
beta = alpha[:] | |
shuffle(beta) | |
cmap = dict(zip(alpha,beta)) | |
# Map the received string to a cryptogram. Note we're not cleaning any input. | |
cryptext = [ cmap[c] if c in alpha else c for c in plaintext.upper()] | |
return ''.join(cryptext) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment