Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Justify, Transpose and Re.Search solution in Clear category for The Hidden Word by mAzrunnr
import re
def justified_text(text):
max_length = max(len(line) for line in text.split("\n"))
return [line.ljust(max_length) for line in text.split("\n")]
def transpose_text(text):
return [''.join(t) for t in zip(*text)]
def checkio(text, word):
text = text.lower().replace(" ", "")
rows = justified_text(text)
for i, row in enumerate(rows):
match = re.search(word, row)
if match:
return [i + 1, match.start() + 1, i + 1, match.end()]
cols = transpose_text(rows)
for i, col in enumerate(cols):
match = re.search(word, col)
if match:
return [match.start() + 1, i + 1, match.end(), i + 1]
return [-1, -1, -1, -1]
Dec. 17, 2023