Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 31st, 2012  |  syntax: Python  |  size: 0.73 KB  |  views: 116  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. def getWordScore(word, n):
  2.     """
  3.    Returns the score for a word. Assumes the word is a valid word.
  4.  
  5.    The score for a word is the sum of the points for letters in the
  6.    word, multiplied by the length of the word, PLUS 50 points if all n
  7.    letters are used on the first turn.
  8.  
  9.    Letters are scored as in Scrabble; A is worth 1, B is worth 3, C is
  10.    worth 3, D is worth 2, E is worth 1, and so on (see SCRABBLE_LETTER_VALUES)
  11.  
  12.    word: string (lowercase letters)
  13.    n: integer (HAND_SIZE; i.e., hand size required for additional points)
  14.    returns: int >= 0
  15.    """
  16.     score = 0
  17.     word_len = len(word)
  18.     for w in word:
  19.         score += SCRABBLE_LETTER_VALUES[w]
  20.     return score*word_len+(50*(word_len/n))