Skip to content

Instantly share code, notes, and snippets.

@Natim
Created September 27, 2013 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Natim/6729868 to your computer and use it in GitHub Desktop.
Save Natim/6729868 to your computer and use it in GitHub Desktop.
Carré de Polybe
# -*- coding: utf-8 -*-
M = [["A", "B", "C", "D", "E"],
["F", "G", "H", "IJ", "K"],
["L", "M", "N", "O", "P"],
["Q", "R", "S", "T", "U"],
["V", "W", "X", "Y", "Z"]]
def decode(texte):
for lettre in texte.split():
if len(lettre) != 2 or not lettre.isdigit() or \
int(lettre) > 55 or int(lettre) < 11:
raise ValueError(lettre)
x, y = [u - 1 for u in map(int, lettre)]
print M[x][y]
texte = raw_input("Tapez le texte à décoder: ")
decode(texte)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment