You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
533 B
Python
22 lines
533 B
Python
2 years ago
|
from string import ascii_uppercase
|
||
|
|
||
|
def generate_grid(word, origin, direction):
|
||
|
|
||
|
start = (
|
||
|
ascii_uppercase.index(origin[0]),
|
||
|
int(origin[1:]),
|
||
|
)
|
||
|
|
||
|
cells = []
|
||
|
for i in range(len(word)):
|
||
|
if direction == "H":
|
||
|
# increase number
|
||
|
start_f = f"{ascii_uppercase[start[0]]}{start[1] + i}"
|
||
|
|
||
|
pass
|
||
|
else:
|
||
|
# increase letter
|
||
|
start_f = f"{ascii_uppercase[start[0] + i]}{start[1]}"
|
||
|
pass
|
||
|
cells.append(start_f)
|
||
|
return cells
|