Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
search(positions, word='hypercube'): solution in Clear category for Hypercube by flpo
def hypercube(grid):
values = {(i, j): char.lower() for i, row in enumerate(grid) for j, char in enumerate(row)}
def search(positions, word='hypercube'):
if not word: return True
candidates = (pos for pos in positions if values[pos] == word[0])
next_pos = ({(x + 1, y), (x, y + 1), (x - 1, y), (x, y - 1)} for x, y in candidates)
return any(search(pos & values.keys(), word=word[1:]) for pos in next_pos)
return search(values)
Sept. 28, 2018