id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

peter@norvig.com scrabble > scrabble_score_word
prev  |  next  |  chance

In this fourth Scrabble exercise, we will determine the score of a word. You will define scrabble_score_word(row, k, word) to return the score for playing word at position k in the row. We extend the notation for rows: a row is still represented as a list of squares, but now a square can be: (1) a letter, (2) the start square, represented by the digit 0, (3) an empty square, or empty double- or triple-letter score square, represented by the integers 1, 2, 3, respectively, (4) an empty double- or triple-word square, represented by -2 or -3, respectively. To compute the score, you add up all the points for the letters first (counting letters double or triple as appropriate), then you multiply by any double or triple word scores (there might be several of these). Finally, if all seven letters were used, add a 35 point bonus. The scores for each letter are as follows: A=1, B=4, C=4, D=2, E=1, F=4, G=3, H=3, I=1, J=10, K=5, L=2, M=4, N=2, O=1, P=4, Q=10, R=1, S=1, T=1, U=2, V=5, W=4, X=8, Y=3, Z=10.


scrabble_score_word([-3, 1, 1, 2, 1, 1, 'O', 'X', 'I', 'D', 'I', 'Z', 'I', 'N', 'G', -3], 0, 'SESQUIOXIDIZINGS') → 539
scrabble_score_word([-3, 1, 2, 1, 'T', 1, 2, 1, -3], 3, 'OTHER') → 8
scrabble_score_word([-3, 1, 2, 1, '*', 1, 2, 1, -3], 0, 'OTHER') → 60

...Save, Compile, Run (ctrl-enter)

def scrabble_score_word(row, k, word):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 473 Post-solution available

Copyright Nick Parlante 2017 - privacy