nagaram/scrabble.py
def word_score(word, input_letters, questions=0):
    """Checks the Scrabble score of a single word.

    Args:
        word: a string to check the Scrabble score of
        input_letters: the letters in our rack
        questions: integer of the tiles already on the board to build on

    Returns:
        an integer Scrabble score amount for the word
    """

    score = 0
    bingo = 0
    filled_by_blanks = []
    rack = list(input_letters)  # make a copy to speed up find_anagrams()
    for letter in word:
        if letter in rack:
            bingo += 1
            score += letter_score(letter)
            rack.remove(letter)
        else:
            filled_by_blanks.append(letter_score(letter))

    # we can have both ?'s and _'s in the word. this will apply the ?s to the
    # highest scrabble score value letters and leave the blanks for low points.
    for blank_score in sorted(filled_by_blanks, reverse=True):
        if questions > 0:
            score += blank_score
            questions -= 1

    # 50 bonus points for using all the tiles in your rack
    if bingo > 6:
        score += 50

    return score
def word_score(word, input_letters, questions=0):
    score = 0
    bingo = 0
    filled_by_blanks = []
    rack = list(input_letters)  # make a copy to speed up find_anagrams()
    for letter in word:
        if letter in rack:
            bingo += 1
            score += letter_score(letter)
            rack.remove(letter)
        else:
            filled_by_blanks.append(letter_score(letter))

    # we can have both ?'s and _'s in the word. this will apply the ?s to the
    # highest scrabble score value letters and leave the blanks for low points.
    for blank_score in sorted(filled_by_blanks, reverse=True):
        if questions > 0:
            score += blank_score
            questions -= 1

    # 50 bonus points for using all the tiles in your rack
    if bingo > 6:
        score += 50

    return score
def word_score ( word , input_letters , questions = 0 ) : score = 0 bingo = 0 filled_by_blanks = [ ] rack = list ( input_letters ) # make a copy to speed up find_anagrams() for letter in word : if letter in rack : bingo += 1 score += letter_score ( letter ) rack . remove ( letter ) else : filled_by_blanks . append ( letter_score ( letter ) ) # we can have both ?'s and _'s in the word. this will apply the ?s to the # highest scrabble score value letters and leave the blanks for low points. for blank_score in sorted ( filled_by_blanks , reverse = True ) : if questions > 0 : score += blank_score questions -= 1 # 50 bonus points for using all the tiles in your rack if bingo > 6 : score += 50 return score
Checks the Scrabble score of a single word.

    Args:
        word: a string to check the Scrabble score of
        input_letters: the letters in our rack
        questions: integer of the tiles already on the board to build on

    Returns:
        an integer Scrabble score amount for the word
Checks the Scrabble score of a single word .