Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import numpy as np
- def board_setup(file, word):
- """
- Purpose:
- To set-up the cross word to allow for searching, and to set up the desired word to be searchable (Capitalizing
- and adding spaces)
- Pre-condition:
- file = The name of a file, must be entered as "file_name.txt" (without " ")
- word = Any word in the english language you desire to find in the cross word (i.e. BADSINGING)
- Post-condition:
- N/a
- Return:
- Returns the cross-word grid in a list of lists, returns the desired word frontwards and backwards i.e. test/tset
- """
- grid = []
- file = open(file, "r")
- for line in file:
- line = line.rstrip()
- line = line.replace(" ","")
- grid.append([line])
- file.close()
- word = word.upper()
- front = word
- back = word[::-1]
- return np.array(grid), front, back
- def search_for_word(grid, word, word_backwards):
- length = len(word)
- for row in grid:
- for col in row:
- for i in col:
- if i == word[0] or i == word_backwards[0]:
- pass
- # console_arg_1 = sys.argv[1] # Enter file name as "file_name.txt" (without " ")
- # console_arg_2 = sys.argv[2] # Enter desired word
- console_arg_1 = "confession.txt"
- console_arg_2 = "REDRUM"
- crossword, frontwards, backwards = board_setup(console_arg_1, console_arg_2)
- if search_for_word(crossword,frontwards,backwards):
- print("GoGo IS GUILTY OF", frontwards, "!")
- else:
- print(frontwards, " was NOT found!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement