Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 14 Online
OpenStudy (anonymous):

ps6 p4 - so i'm trying to figure out the most efficient way of sorting a string by the values of the characters in the string according to the scrabble value dictionary. At the moment I'm thinking I should create a dictionary of the word, then use import operator and itemgetter to create a sorted list of tuples as a representation, and then slice that list of tuples up to extract the sorted word. But this seems to me an enormously laborious process... and besides I haven't seen itemgetter in the lectures yet... so there must be a more efficient way to do this surely?

OpenStudy (anonymous):

just because you haven't seen it in a lecture doesn't mean you cannot use it this is not a Python class I am not sure i understand - you want to rearrange the letters in a string so that they are ordered according to their scrabble point values? have you read this? http://docs.python.org/howto/sorting.html http://docs.python.org/library/functions.html#sorted use the sorted function with a custom comparison function

OpenStudy (anonymous):

spoiler - http://codepad.org/JVabgH3m

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!