Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
__ solution in Clear category for The Hidden Word by Cjkjvfnby
from itertools import zip_longest
def find_start(text, word):
"""
Find word stat position in text.
Line numeration from starts 1.
"""
start_pos = text.find(word)
if start_pos >= 0:
line_number = text.count('\n', 0, start_pos)
line_start = text.rfind('\n', 0, start_pos)
row_start = line_number + 1
column_start = start_pos - line_start
return row_start, column_start
def checkio(text, word):
text = text.replace(' ', '').lower()
distance = len(word) - 1
start = find_start(text, word)
if start:
row_start, column_start = start
return [row_start, column_start, row_start, column_start + distance]
else:
text = '\n'.join(''.join(x) for x in zip_longest(*text.split('\n'), fillvalue=''))
start = find_start(text, word)
column_start, row_start = start
return [row_start, column_start, row_start + distance, column_start]
Feb. 7, 2014
Comments: