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 koladen
from itertools import zip_longest
def checkio(text, word):
my_list = [''.join(i.split()) for i in text.lower().split('\n')]
for i in range(len(my_list)):
result = my_list[i].find(word.lower())
if result > 0:
return [i + 1, result + 1, i + 1, result + len(word)]
zipp_my_list = []
zipped_array = list(map(list, list(zip_longest(*my_list))))
for sub in zipped_array:
zipp_my_list.append([i for i in sub if i is not None])
zipp_my_list = [''.join(i) for i in zipp_my_list]
for i in range(len(zipp_my_list)):
result = zipp_my_list[i].find(word.lower())
if result != -1:
return [result + 1, i + 1, result + len(word), i + 1]
Nov. 2, 2020