Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
zip_longest solution in Clear category for The Hidden Word by zwerkoff
from itertools import zip_longest
def search_word(l: list, word: str, row: int):
for j, i in enumerate(l):
if i.find(word) != -1:
return [j + 1, i.find(word) + 1, j + 1, i.find(word) + len(word)] if row else [i.find(word) + 1, j + 1, i.find(word) + len(word), j + 1]
def checkio(text: str, word: str):
rows = text.lower().replace(' ', '').split(f'\n')
cols = [''.join(i) for i in list(zip_longest(*rows, fillvalue='-'))]
return search_word(rows, word, 1) if search_word(rows, word, 1) else search_word(cols, word, 0)
Sept. 14, 2020
Comments: