I want to my program to take 25 letters as input and put them in some sort of list so that i can make rules for what letter that can connect with another until and get three words from it that is not overlapping.
What i did was this:
def matris():
matris = [[],[],[],[],[]]
counter = 0
counter2 = 0
counter3 = 0
counter4 = 0
counter5 = 0
while counter !=5:
matris[0].append(raw_input('One letter: '))
counter+=1
while counter2 !=5:
matris[1].append(raw_input('One letter: '))
counter2+=1
while counter3 !=5:
matris[2].append(raw_input('One letter: '))
counter3+=1
while counter4 !=5:
matris[2].append(raw_input('One letter: '))
counter4+=1
while counter5 !=5:
matris[4].append(raw_input('One letter: '))
counter5+=1
return matris
So for example, when I run this it ask me for "One letter" * 25 which could generate a matrix looking something like this:
matris = [['a', 'g', 'i', 't', 'u']
['s', 'r', 'g', 's', 'm']
['f', 'e', 'd', 'c', 't']
['r', 's', 'i', 'f', 'x']
['t', 'i', 't', 't', 'i']]
If anyone have a better way for doing this, I would be thankful if you shared it. And a way that will work with what I want my program to do, which im not sure I will be able to with my version.
I have a dictionary.txt which I have made something like: dictionary = open('dictionary.txt', 'r')
so i thought that i would try to start matching matris[0][0]+matris[0][1]
and see if there is a word starting with i.e 'a'+'g'
, and then take the next letter and so on until you find the lets say three best (most valued) words.
I'm guessing that i would need a class. So this is how far I have come:
Class hypotes:
def __init__ (self, usedPosiiton, word):
self.u = usedPosition
self.w = word
positions = []
bestWords = [] # There should be maximum three words in this list,
# the words with highest score
I thought that I have to save the positions in an array, so that I later on can make sure that the words that are best don't use the same letters?
Guessing I'm going to need some help with this class.
letterValuePoints = {'A':50, 'B':110, 'C':190, 'D':70, 'E':50, 'F':90,
'G':70, 'H':70, 'I':50, 'J':170, 'K':70, 'L':50,
'M':70, 'N':50, 'O':70, 'P':110, 'R':50, 'S':50,
'T':50, 'U':110, 'V':90, 'X':190, 'Y':170, 'Z':210,
'Å':110, 'Ä':90, 'Ö':110}
I thought later on when I would give each letter a value, I would do it like this, but I dont know if that will be a good way?