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 janusztracz73ms
def checkio(tekst, slowo):
tekst = tekst.lower().replace(" ", "")
bolo = tekst.split('\n')
print(len(bolo))
poczatek, koniec = wyszukaj(bolo, slowo)
rozw = []
rozw.append(poczatek[0])
rozw.append(poczatek[1])
rozw.append(koniec[0])
rozw.append(koniec[1])
print(rozw)
return rozw
# czesc 2
def wyszukaj(bolo, slowo):
for row in bolo:
if slowo in row:
pocz = [bolo.index(row) + 1, row.index(slowo[0]) + 1] #1 przyp dla poziomego slowa
koniec = [bolo.index(row)+1, row.index(slowo[0]) + len(slowo)]
return pocz, koniec
for row in bolo:
for b in range(len(row)): #2 przyp dla pionowego slowa
if row[b] == slowo[0]:
pocz = [(bolo.index(row)) + 1, b + 1]
wspolrz = [(bolo.index(row)), b]
for x in slowo[1:]:
print(wspolrz[1])
print(len(bolo))
if bolo[wspolrz[0] + 1][wspolrz[1]] == x:
if x == slowo[len(slowo) - 1]:
wspolrz[0] += 1
wspolrz[0] += 1
wspolrz[1] += 1
return pocz, wspolrz
wspolrz[0] += 1
slozo = slowo[2:]
for z in range(len(slozo)):
print(slozo[z])
print(bolo[wspolrz[0] + 1][wspolrz[1]])
if bolo[wspolrz[0] + 1][wspolrz[1]] == slozo[z]:
if z == len(slozo) - 1:
wspolrz[0] += 1
wspolrz[0] += 1
wspolrz[1] += 1
return pocz, wspolrz
wspolrz[0] += 1
else:
break
else:
break
checkio("xa\nxb\nx","ab")
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio("""DREAMING of apples on a wall,
And dreaming often, dear,
I dreamed that, if I counted all,
-How many would appear?""", "ten") == [2, 14, 2, 16]
assert checkio("""He took his vorpal sword in hand:
Long time the manxome foe he sought--
So rested he by the Tumtum tree,
Andstoodawhileinthought.
Andasinuffishthought he stood,
The Jabberwock, with eyes of flame,
Came whiffling through the tulgey wood,
And burbled as it came!""", "noir") == [4, 16, 7, 16]
Nov. 3, 2016