Problem 3052. Scrabble Scores - 7
This problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided here. (Use the English points distribution.)
For this problem, you will be provided with a character matrix representing a completed game of Scrabble. You will also be provided with the number of players (two to four) and an order array denoting the order of word placement.
The order array is a one-dimensional cell array equal in size to the number of turns in the game. Within each cell element, the coordinates of the currently played word will map the letters placed for each move as row,column or word beginning and row,column of word ending. Since words can only be placed horizontally or vertically, one set of indices (row or column) will be static within each element.
As an example, suppose you are given the following board (this is test case 1):
cat i p t poet c l there
The accompanying order array will have a form like the following:
order(1) = {[2,2; 5,2]}; order(2) = {[5,1; 5,5]}; order(3) = {[1,5; 5,5]}; order(4) = {[3,5; 3,8]}; order(5) = {[1,4; 1,6]};
signifying that the first word is itch, the second word is there, and so on with apple, poet, and cat. For this case, there are two players, and we will assume (for all cases) that no one passes a turn. Therefore, words 1, 3, and 5 belong to player one, totaling 1+1+3+4, 1+3+3+1+1, and 3+1+1, which sums to 23. Words 2 and 4 belong to player one, totaling 1+4+1+1+1 and 3+1+1+1, which sums to 14. Therefore, the function should return [23 14].
If there had been three players, words 1 and 4 would belong to player one, words 2 and 5 to player two, and word 3 to player three.
Finally, the order array will include all scored words for each turn. For instance, if a word starting with S was played off of an existing word, the order array for that turn will have two index sets, as both words would be scored. The order array element will have dimensions 2 x 2 x n where n is the number of words scored on the given turn.
Write a function to calculate and return the total score for each player for the provided Scrabble boards.
Related problems:
Previous problem: 6 - Board scoring. Next problem: 8 - Multiplayer multiplier board scoring.
Solution Stats
Problem Comments
-
3 Comments
Slow activity on Cody, no ?
Yep. Is this the slowest you've ever seen? At this rate, I don't have much hope to get some of the badges (e.g., Quiz Master or Likeable).
Yes, since 2 ou 3 months. I have the feeling that heroes are tired...
Solution Comments
Show commentsProblem Recent Solvers24
Suggested Problems
-
Find the alphabetic word product
3325 Solvers
-
Extract leading non-zero digit
2134 Solvers
-
807 Solvers
-
Area of an equilateral triangle
6191 Solvers
-
Big numbers, least significant digits
94 Solvers
More from this Author139
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!