Advertisement
Guest User

project

a guest
May 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. import sys
  2. import numpy as np
  3.  
  4. def board_setup(file, word):
  5. """
  6. Purpose:
  7. To set-up the cross word to allow for searching, and to set up the desired word to be searchable (Capitalizing
  8. and adding spaces)
  9. Pre-condition:
  10. file = The name of a file, must be entered as "file_name.txt" (without " ")
  11. word = Any word in the english language you desire to find in the cross word (i.e. BADSINGING)
  12. Post-condition:
  13. N/a
  14. Return:
  15. Returns the cross-word grid in a list of lists, returns the desired word frontwards and backwards i.e. test/tset
  16. """
  17. grid = []
  18. file = open(file, "r")
  19. for line in file:
  20. line = line.rstrip()
  21. line = line.replace(" ","")
  22. grid.append([line])
  23. file.close()
  24. word = word.upper()
  25. front = word
  26. back = word[::-1]
  27. return np.array(grid), front, back
  28.  
  29.  
  30. def search_for_word(grid, word, word_backwards):
  31. length = len(word)
  32. for row in grid:
  33. for col in row:
  34. for i in col:
  35. if i == word[0] or i == word_backwards[0]:
  36. pass
  37.  
  38. # console_arg_1 = sys.argv[1] # Enter file name as "file_name.txt" (without " ")
  39. # console_arg_2 = sys.argv[2] # Enter desired word
  40. console_arg_1 = "confession.txt"
  41. console_arg_2 = "REDRUM"
  42. crossword, frontwards, backwards = board_setup(console_arg_1, console_arg_2)
  43.  
  44.  
  45. if search_for_word(crossword,frontwards,backwards):
  46. print("GoGo IS GUILTY OF", frontwards, "!")
  47. else:
  48. print(frontwards, " was NOT found!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement