Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
12-liner: optimized thanks to Phil15 solution in Clear category for Cipher Crossword by Stensen
from itertools import permutations
def match(words, values):
d = {}
for R, V in zip(words, values):
if any(d.setdefault(v, c) != c for c, v in zip(R, V)): return False
return d
def checkio(crossword, words):
lines = crossword[::2] + list(zip(*crossword))[::2]
for perm in permutations(words):
if d:=match(perm, lines):
return [[d.get(c, ' ') for c in row] for row in crossword]
return None
Nov. 22, 2020