Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Hidden Word by mozurin
import itertools
def checkio(text, word):
matrix = [row.lower().replace(' ', '') for row in text.split('\n')]
for trans in (False, True):
for rnum, row in enumerate(matrix):
try:
found = row.index(word)
r = [rnum + 1, found + 1, rnum + 1, found + len(word)]
return list(
itertools.chain.from_iterable(
zip(r[trans::2], r[not trans::2])
)
)
except ValueError:
pass
matrix = [
''.join(c if c else '\0' for c in r)
for r in itertools.zip_longest(*matrix)
]
May 16, 2017
Comments: