Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
5 lines brute force solution in Creative category for Cipher Crossword by CDG.Axel
def checkio(crossword, words, perm=__import__('itertools').permutations):
lines = crossword[::2] + [*zip(*crossword)][::2]
for choice in perm(words):
dd = {0: ' '}
if all(dd.setdefault(dig, let) == let for p, l in zip(choice, lines) for let, dig in zip(p, l)):
return [[dd[dig] for dig in row] for row in crossword]
if __name__ == '__main__':
assert checkio(
[
[21, 6, 25, 25, 17],
[14, 0, 6, 0, 2],
[1, 11, 16, 1, 17],
[11, 0, 16, 0, 5],
[26, 3, 14, 20, 6]
],
['hello', 'habit', 'lemma', 'ozone', 'bimbo', 'trace']) == [['h', 'e', 'l', 'l', 'o'],
['a', ' ', 'e', ' ', 'z'],
['b', 'i', 'm', 'b', 'o'],
['i', ' ', 'm', ' ', 'n'],
['t', 'r', 'a', 'c', 'e']]
Dec. 13, 2021