so i have a problem, I'm doing a class project where we need to implement so me backtracking to solve a crossword, given a dictionary of words of different sizes, so the problem is I want to implement a fast way to acces to these words of dictionary, so I use a dictionary of numpy, where the keys are the length of the words and as value, there's a numpy array of the words.
for now i have a structure similar to :
words[4] :{['ABBS','BACK',...,'zeal']}
but I'm looking for a structure that i can acces to every single characters of words so its easier for me to sort the words from dictionary, the structure I want to have is like:
words[4]:{['A','B','B','S'],['B','A','C','K'], ...,['Z','E','A','L']}
I have been trying many methods convert the string into a list of characters but it's not working.
what I'm doing is:
dictionaryF = open(self.dictionaryFile,'r')
dictionary = {}
words = dictionaryF.readlines()
dictionaryF.close()
length = np.array([len(i) for i in words])
for i in self.maxLen:
dictionary[i] = np.array( words[np.where(length==i)])
self.dictionary = dictionary
self.maxLen is a list with the unique lengths of the words in crossword, I use it to not a have innecessary words.
self.dictionary is ths dictionary for solving which i will save ina attribute of my class.
I need a fast way to read and process all this so it doesn't take hours to read a file, because i need to read up to 600 thousand words sometimes.
all this is to slve faster the crossword, suppose u have a crossword like:
0 0 0 # 0 0
0 # 0 0 0 0
0 # 0 # 0 0
0 0 0 0 # 0
0 # 0 # 0 0
0 0 0 0 0 #
# 0 # 0 0 #
0`s are the empty positions where you can assign a word, so as you can see there are some position where two words intersect, and for these i need to sort out from dictionary of wordsthe one with same value of the assigned word on intersection, for example:
on first row the first three positions u can assign ABS, if u wanna assign a word on first column, it needs to start by A.