-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapitalize_word_in_crossword.py
More file actions
41 lines (32 loc) · 1.33 KB
/
capitalize_word_in_crossword.py
File metadata and controls
41 lines (32 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def capitalize_word_in_crossword (crossword,word):
def find_word_horizontal(crossword,word):
w_l = list (word)
d = len (w_l)
for i in crossword:
m = crossword.index(i)
for k in i:
n = i.index(k)
if w_l == i[n:(n+d)]:
i[n:(n+d)] = [x.upper() for x in i[n:(n+d)]]
return (crossword)
def find_word_vertical(crossword,word):
w_l = list (word)
d = len (w_l)
soton = [list(i) for i in zip(*crossword)]
for i in soton:
m = soton.index(i)
for k in i:
n = i.index(k)
if w_l == i[n:(n+d)]:
i[n:(n+d)] = [X.upper() for X in i[n:(n+d)]]
crossword = [list(x) for x in zip(*soton)]
return (crossword)
if find_word_horizontal(crossword,word) != crosswords:
print ('horizontal', crossword)
elif find_word_vertical(crossword,word) != crosswords:
print ('vertical', crossword)
else:
print ('None')
crosswords=[['a','b','c','d'],['e','c','a','b'],['i','a','t','l'],['m','t','o','p']]
word='cat'
capitalize_word_in_crossword (crosswords,word)