Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Used What I've learnt lately :D Walruses, numpy.trnaspose and right padding(ljust) solution in 3rd party category for The Hidden Word by Stensen
import numpy as np
def transpose_and_join(A):
arr = list(map(lambda i: list(i.ljust(len(max(A, key=len)))), A))
return list(map(''.join, np.array(arr).T))
def checkio(t, w):
cut = t.lower().replace(' ', '').splitlines()
# Find the word inside the Rhyme Horizontally
for row_start, a in enumerate(cut):
if w in a: return [row_start+1,index_start:=a.index(w)+1, row_start+1, index_start+len(w)-1]
# Find the word inside the Rhyme Verticallly
for column_start, a in enumerate(transpose_and_join(cut)):
if w in a: return [index_start:=a.index(w)+1, column_start+1, index_start+len(w)-1, column_start+1]
Sept. 28, 2020