This is the code for the main body. Which goes through a string of character formats them and then searches words in a inputed list. the string of characters is
'WAQHGTTWEECBMIVQQELSAZXWKWIIILLDWLFXPIPVPONDTMVAMNOEDSOYQGOBLGQCKGMMCTYCSLOACUZMXVDMGSXCYZUUIUNIXFNU'
and the string of words is 'UNIX CALPOLY GCC SLO COMPILE VIM TEST'
my code correctly finds the words in all directions how ever the issue is when it doesn't find the word.
import funcs
def main():
rawPuzzle = funcs.create_puzzle()
words = funcs.get_words()
funcs.print_puzzle(rawPuzzle)
puzzle = funcs.format_puzzle(rawPuzzle)
vertPuzzleRaw = funcs.make_vert_puzzle(puzzle)
vertPuzzle = funcs.format_vert_puzzle(vertPuzzleRaw)
for x in range(len(words)):
word = words[x]
for l in range(len(puzzle)):
forward = funcs.check_forward(puzzle, word, l)
if forward != -1:
print(word, ': (FORWARD)', 'row: ', l, 'column: ', forward)
backward = funcs.check_backward(puzzle, word, l)
if backward != -1:
print(word, ': (BACKWARD)', 'row: ', l, 'column: ', (9 - backward))
down = funcs.check_down(vertPuzzle, word, l)
if down != -1:
print(word, ': (DOWN)', 'row: ', down, 'column: ', l)
up = funcs.check_up(vertPuzzle, word, l)
if up != -1:
print(word, ': (UP)', 'row: ', (9 - up), 'column: ', l)
if forward and backward and down and up == -1:
print(word, ': word not found')
if __name__ == '__main__':
main()
and the output looks like this:
Puzzle:
WAQHGTTWEE
CBMIVQQELS
AZXWKWIIIL
LDWLFXPIPV
PONDTMVAMN
OEDSOYQGOB
LGQCKGMMCT
YCSLOACUZM
XVDMGSXCYZ
UUIUNIXFNU
UNIX : word not found
UNIX : word not found
UNIX : word not found
UNIX : word not found
UNIX : word not found
UNIX : word not found
UNIX : word not found
UNIX : word not found
UNIX : word not found
UNIX : (FORWARD) row: 9 column: 3
UNIX : word not found
CALPOLY : (DOWN) row: 1 column: 0
CALPOLY : word not found
CALPOLY : word not found
CALPOLY : word not found
CALPOLY : word not found
CALPOLY : word not found
CALPOLY : word not found
CALPOLY : word not found
CALPOLY : word not found
CALPOLY : word not found
CALPOLY : word not found
GCC : word not found
GCC : word not found
GCC : word not found
GCC : word not found
GCC : word not found
GCC : word not found
GCC : word not found
GCC : word not found
GCC : word not found
GCC : word not found
SLO : word not found
SLO : word not found
SLO : word not found
SLO : word not found
SLO : word not found
SLO : word not found
SLO : word not found
SLO : (FORWARD) row: 7 column: 2
SLO : word not found
SLO : word not found
SLO : word not found
COMPILE : word not found
COMPILE : word not found
COMPILE : word not found
COMPILE : word not found
COMPILE : word not found
COMPILE : word not found
COMPILE : word not found
COMPILE : word not found
COMPILE : (UP) row: 6 column: 8
COMPILE : word not found
VIM : word not found
VIM : (BACKWARD) row: 1 column: 4
VIM : word not found
VIM : word not found
VIM : word not found
VIM : word not found
VIM : word not found
VIM : word not found
VIM : word not found
VIM : word not found
VIM : word not found
TEST : word not found
TEST : word not found
TEST : word not found
TEST : word not found
TEST : word not found
TEST : word not found
TEST : word not found
TEST : word not found
TEST : word not found
TEST : word not found
Process finished with exit code 0 I cant make it not print the "word not found" if it finds the word and I can't make it print it only once for when the words really is not found in the puzzle