Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Cipher Crossword by Moff
from itertools import permutations
def checkio(cipher_cross, words):
cipher_cross_t = list(map(list, zip(*cipher_cross)))
cipher_words = [cipher_cross[i] for i in (0, 2, 4)] + [cipher_cross_t[i] for i in (0, 2, 4)]
for perm in permutations(words):
chars = dict()
valid = True
for cipher, word in zip(cipher_words, perm):
for k, c in zip(cipher, word):
if chars.get(k, c) != c:
valid = False
chars[k] = c
if valid:
break
return [[chars.get(i, ' ') for i in row] for row in cipher_cross]
Sept. 11, 2015