Problem 3098. Scrabble Scores - 13
This problem integrates components of Scrabble Scores - 11 and Scrabble Scores - 12. Here, you are provided an existing word on the board from which you will play a word. The letter can reside anywhere (first to last) within the existing word and within the word that you are playing. In addition, multipliers from the board are provided. Write a function to find the highest scoring word, provided any letter from the existing word that you are building off of, the letters on your tray, and the multipliers (provided in specific locations; see below).
Rather than having to test all the possible permutations against a dictionary, you will be provided a double-level cell array of strings containing all possible words based each starting letter in the existing word and the letters on your tray (a cell array for each letter in the existing word). (The word lists purposefully omit smaller words to prevent the test cases from being too large.) In addition to providing the highest score, also provide the word(s) that achieve that score in a cell array. See the test suite for examples. Due to high-scoring tiles, the highest score may not be achieved by the longest word(s).
You will be provided a multiplier character array that represents the fifteen possible squares that can be played on for each letter in the existing word, ranging from seven above each existing letter (in which case the existing letter is the last letter in an eight-letter word) to seven below each existing letter (in which case the existing letter is the first letter in an eight-letter word) with the existing letter fixed in the 8th (column) position. The array will have the same number of rows as the length of the existing word (which is located along the middle of the array). The multipliers are the same as in previous problems:
* D: double word * T: triple word * Q: quadruple word * d: double letter * t: triple letter * q: quadruple letter
The center multiplier square will be left blank, since it's already covered by a tile.
Related problems:
Previous problem: 12 - Word score optimization (first word).
Solution Stats
Problem Comments
-
6 Comments
Hello Grant, how 'althea' in 2nd test is scored? I get (1+1*2+1+4+1+1)*2 = 20, but max_score_corr in this test is 44. My code has found 'maltha' for 30 points.
I get the same result with Jan Orwat
In 6th test, case 2 my code has found 'medico' for 28 points instead of 'chez','zaideh' and 'chimed' for 21. Same test, case 1 gives 'haemoid' for 117 points instead of 26 for 'cohead','chimla' and 'gached'. In 4th test, case 2 I've got 16 points for 'iodine', and 16 also for 'endrin', 'indole', 'ironed' and 'linden'.
Jan & Binbin, thank you for your patience and in-depth error reporting. I was able to get the test suite and my code fixed to now report the same values that you found. I'm not sure how quickly the rescoring will propagate, so you might want to submit your solutions again. In case you're curious, there were two reasons for these errors. First, I had copied the word cell lists for starting words that had repeated letters (e.g., zoologist) but had failed to change the indices for the repeated letters. Second, my routine counted the multipliers outside of the loop on the starting index, so words with repeated letters that coincided with the tile in the starting word (e.g., a in althea) got their multiplier squares artificially doubled. But, all should be fixed now.
Hi Grant, after solving all your previous problems in this series, I get confused by the very last problem. What’s the score of a word if two different existing letters appear in the same word? Taking the first test case as an example, two existing letters 's' and 'a' (out of the first_word 'start') both appear in the same word 'atheism' (i.e., words{1}{end-3} ). When considering 's' as the existing letter, the corresponding multiplier for the word 'atheism' is ' d ' (i.e.,3 spaces + 'd' + 3 spaces, or mult(1, 3:9) ) and the score of 'atheism' calculates to 13. On the other hand, if we consider 'a' as the existing letter, then 'a' becomes the starting letter of 'atheism'. In this case, the multiplier for the word 'atheism' is ' d T' (i.e., 2 spaces + d + 3 spaces + T, or mult(1, 8:14) ) and the score becomes 48. But the reference solution for test case 1 has a max_score_corr = 39, a score smaller than 48. I guess this mismatch is due to the confusion on how to determine the score when different existing letters appear in the same word. Could you please provide some explanations? BTW, Thanks for the nice series of problems!
Thanks for your interest in the problem set. It took a while to construct, so it's nice to see it being used. You seem to have the scoring method down. The hang up here is the possible word sets for each starting letter. Due to the lack of a dictionary, I pre-compiled all the possible words for each starting letter. For each, the respective starting letter is combined with tray letters (included in the test suites for informational purposes) to pre-construct the possible-word list. For the first test suite, the tray letters are: aethilm. Combined with s (the first starting-word letter), you can spell atheism. However, when combined with a (the third starting-word letter you reference here), atheism can no longer be spelled, as there is no s in the set of tray letters. So, your scoring is right, but not possible in this case due to the existing tray letters. I formulated the problem so that you don't have to worry about existing tray letters and only need to test against the pre-compiled word sets (cell arrays) for each starting-word letter.
Solution Comments
Show commentsProblem Recent Solvers15
Suggested Problems
-
Project Euler: Problem 1, Multiples of 3 and 5
3169 Solvers
-
Are all the three given point in the same line?
415 Solvers
-
409 Solvers
-
Divisible by n, Composite Divisors
71 Solvers
-
308 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!