Advertisement
Guest User

Untitled

a guest
Oct 31st, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  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))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement