PS6#3.I am just blanking,forgetting everything and with dictionary trouble.Help with 'get_words_to_points(word_list),please. http://codepad.org/bFrPW3dS There is some semblance of a start.Just cannot remember the syntax rules of everything and when certain attributes and lines are necessary(yes,the most basic bits).Yes,I read but it doesn't make sense as a whole.I might go back and grab here and there but that is not great.Sorry to be such a dope.Also,is this all there is to update? http://codepad.org/SJSm2WI8 Thank you
def get_words_to_points(): get_points_dict = {} print 'Loading point values of words ...' ## cycles through the wordlist creating a dictionary ## with the word as the key and the point value as the entry for index in range(len(word_list)): get_points_dict[word_list[index]] = get_word_score(word_list[index],HAND_SIZE) return get_points_dict I think this works
Hey,thanks for the response.Looks OK(just changed my own notation)but I am not in position to question another. That is sort of the method from earlier, have you tried using any of the shortcut tools for dictionaries? Wondering if those could be useful/better or even applicable. Also,did you check out my second link for the update using the dictionary? Seems stupid and wrong but maybe.
what are the dictionary shortcut tools? you could do it when you first load the words: http://dpaste.com/695441/ why do you think your updated is_valid_word function is wrong? does it work? here is mine: http://dpaste.com/695442/
Don't know if updated is_valid_word works.Honestly,one big issue is I just lose track of variables and what is temp and what is Python language.Just overwhelmed to try to just test this piece and figured someone could tell with a look. So when you are looking for strings in a dictionary, you can just name the dictionary, no need to name keys or values?I see in yours you just have 'word' and points_dict and I had points_dict(keys) thinking it was only looking through those and trying to be careful.
i think keys is the default if not specified - don't know where i read that, probably somewhere in the docs didn't you test it before you posted it? tsk, tsk looks like it might work to me. here is a test i wrote for mine: http://dpaste.com/695491/
Here are some pieces of code for parts of the problem.Any scoldings on all the things I left out or are needed in there are welcome.I am not sure of the syntax and use in certain cases(and I looked around),especially line 29 and 25,trying to pick out the key and add it to the list and then sort it pick out last(highest value/score).But I have confused how to use the functions.I changed my approach to the problem after being sort of through it.Here is the link. http://codepad.org/7O7c9Toh
lines 23-31 will find the highest score but doesn't preserve the word itself. I think you need to use itertools permutations with points_dict - consider the hand 'dbac' it.combinations won't produce the word bad but permutations will http://dpaste.com/696045/
Join our real-time social learning platform and learn together with your friends!