Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Cipher Crossword by TovarischZhukov
from copy import deepcopy
coords=[(0,0,1),(0,0,0),(0,2,1),(2,0,0),(0,4,1),(4,0,0)]
def find(cross,words,alph,cors):
if not words: return cross
word=words[0]
words=words[1:]
for cor in cors:
err_flag=False
n_alph=alph.copy()
n_cross=deepcopy(cross)
n_coords=cors[:]
n_coords.remove(cor)
for k in range(5):
val=word[k]
if not cor[2]:
i=cor[0];j=k
else:
i=k;j=cor[1]
if val not in n_alph:
n_alph[val]=n_cross[i][j]
elif type(n_cross[i][j])==int and n_alph[val]!=n_cross[i][j]:
err_flag=True
break
n_cross[i][j]=val
if err_flag: continue
r=find(n_cross,words,n_alph,n_coords)
if r: return r
def checkio(crossword, words):
for i,el in enumerate(crossword):
for j,val in enumerate(el):
if not val: crossword[i][j]=" "
return find(crossword, words, {}, coords)
Feb. 15, 2016