{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":3047,"title":"Scrabble Scores - 2","description":"An \u003chttps://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores introductory Cody problem\u003e asks the user to score a Scrabble word. This problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine.\r\n\r\nScrabble is a word board game wherein each letter tile is scored roughly according to its frequency (or lack thereof) in words. More common letters, such as vowels, are worth fewer points while difficult letters, such as Q, Z, J, and X are worth more points. The point distribution is provided \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you will be provided with a cell array of words (e.g., all the words from one player in a game). Write a function to calculate the total score for the set of words.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 1 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores Single-word scoring\u003e. Next problem: 3 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3 Single-word multiplier scoring\u003e.\r\n","description_html":"\u003cp\u003eAn \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores\"\u003eintroductory Cody problem\u003c/a\u003e asks the user to score a Scrabble word. This problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine.\u003c/p\u003e\u003cp\u003eScrabble is a word board game wherein each letter tile is scored roughly according to its frequency (or lack thereof) in words. More common letters, such as vowels, are worth fewer points while difficult letters, such as Q, Z, J, and X are worth more points. The point distribution is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a cell array of words (e.g., all the words from one player in a game). Write a function to calculate the total score for the set of words.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 1 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores\"\u003eSingle-word scoring\u003c/a\u003e. Next problem: 3 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3\"\u003eSingle-word multiplier scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_2(words)\r\n\r\nscore = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nwords = {'hello','there','fellow','matlab','users'};\r\nscore = 43;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%%\r\nwords = {'what','do','you','think','of','this','problem'};\r\nscore = 56;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%%\r\nwords = {'if','you','like','it','please','give','it','a','like'};\r\nscore = 48;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%%\r\nwords = {'zither','quandry','flummox','wealthy','amalgam'};\r\nscore = 87;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%%\r\nwords = {'one','two','three','four','five'};\r\nscore = 34;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%%\r\nwords = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\nscore = [17 21 15 12 5];\r\nind = randi(5);\r\nassert(isequal(scrabble_scores_2(words(ind)),score(ind)))\r\n\r\n%%\r\nwords = {'perspicacious','yes','zero','quizzical','no'};\r\nscore = [21 6 13 38 2];\r\nind = randi(5);\r\nassert(isequal(scrabble_scores_2(words(ind)),score(ind)))\r\n\r\n%% pangram test (one string) to help ensure letters scores are correctly assigned\r\nwords = {'the quick brown fox jumps over a lazy dog'};\r\nscore = 94;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%% pangram test (multiple words) to help ensure letters scores are correctly assigned\r\nwords = {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\nscore = 94;\r\nassert(isequal(scrabble_scores_2(words),score))","published":true,"deleted":false,"likes_count":2,"comments_count":7,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":"2015-02-28T02:22:30.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-02-26T04:07:25.000Z","updated_at":"2026-04-02T20:07:44.000Z","published_at":"2015-02-26T04:07:24.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAn\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eintroductory Cody problem\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e asks the user to score a Scrabble word. This problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eScrabble is a word board game wherein each letter tile is scored roughly according to its frequency (or lack thereof) in words. More common letters, such as vowels, are worth fewer points while difficult letters, such as Q, Z, J, and X are worth more points. The point distribution is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a cell array of words (e.g., all the words from one player in a game). Write a function to calculate the total score for the set of words.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 1 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSingle-word scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 3 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSingle-word multiplier scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3018,"title":"Calculator spelling - Numbers to Letters","description":"Using the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\r\n\r\n* 0 = O\r\n* 1 = I\r\n* 2 = Z\r\n* 3 = E\r\n* 4 = h\r\n* 5 = S\r\n* 6 = g\r\n* 7 = L\r\n* 8 = B\r\n\r\nThere are a few other options, but we'll stick with these. The number may be a have a decimal with a leading zero, to produce a trailing O. If this is the case, ignore the decimal point. Write a function that takes a number as input and returns the word spelled (upside down) by the calculator. Make sure to get the case (capital vs. lowercase) right for each number/letter.\r\n\r\nThis problem is related to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3019-calculator-spelling-letters-to-numbers Problem 3019\u003e.","description_html":"\u003cp\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\u003c/p\u003e\u003cul\u003e\u003cli\u003e0 = O\u003c/li\u003e\u003cli\u003e1 = I\u003c/li\u003e\u003cli\u003e2 = Z\u003c/li\u003e\u003cli\u003e3 = E\u003c/li\u003e\u003cli\u003e4 = h\u003c/li\u003e\u003cli\u003e5 = S\u003c/li\u003e\u003cli\u003e6 = g\u003c/li\u003e\u003cli\u003e7 = L\u003c/li\u003e\u003cli\u003e8 = B\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThere are a few other options, but we'll stick with these. The number may be a have a decimal with a leading zero, to produce a trailing O. If this is the case, ignore the decimal point. Write a function that takes a number as input and returns the word spelled (upside down) by the calculator. Make sure to get the case (capital vs. lowercase) right for each number/letter.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3019-calculator-spelling-letters-to-numbers\"\u003eProblem 3019\u003c/a\u003e.\u003c/p\u003e","function_template":"function [word] = calc_spell_word(n)\r\n\r\nword = num2str(n);\r\n\r\nend\r\n","test_suite":"%%\r\nn = 35007;\r\ntxt = 'LOOSE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 77345;\r\ntxt = 'ShELL';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 36138;\r\ntxt = 'BEIgE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 378806;\r\ntxt = 'gOBBLE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 376006;\r\ntxt = 'gOOgLE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 57738461375;\r\ntxt = 'SLEIghBELLS';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 0.7734;\r\ntxt = 'hELLO';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 53045;\r\ntxt = 'ShOES';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 771;\r\ntxt = 'ILL';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 345;\r\ntxt = 'ShE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 7735;\r\ntxt = 'SELL';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nind = randi(4);\r\nn_arr = [36138 707 7714 57738];\r\nn = n_arr(ind);\r\ntxt_arr = {'BEIgE','LOL','hILL','BELLS'};\r\ntxt = txt_arr{ind};\r\nassert(isequal(calc_spell_word(n),txt))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":72,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-14T22:05:44.000Z","updated_at":"2026-03-19T20:03:05.000Z","published_at":"2015-02-14T22:05:44.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e0 = O\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1 = I\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2 = Z\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e3 = E\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e4 = h\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e5 = S\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e6 = g\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e7 = L\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e8 = B\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThere are a few other options, but we'll stick with these. The number may be a have a decimal with a leading zero, to produce a trailing O. If this is the case, ignore the decimal point. Write a function that takes a number as input and returns the word spelled (upside down) by the calculator. Make sure to get the case (capital vs. lowercase) right for each number/letter.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3019-calculator-spelling-letters-to-numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3019\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3019,"title":"Calculator spelling - Letters to Numbers","description":"Using the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\r\n\r\n* 0 = O\r\n* 1 = I\r\n* 2 = Z\r\n* 3 = E\r\n* 4 = h\r\n* 5 = S\r\n* 6 = g\r\n* 7 = L\r\n* 8 = B\r\n\r\nThere are a few other options, but we'll stick with these. If the word has a trailing O, the number will need a decimal point to produce a leading zero. Write a function that takes a word (upside down) as input and returns the number entered into the calculator.\r\n\r\nThis problem is related to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3018-calculator-spelling-numbers-to-letters Problem 3018\u003e.","description_html":"\u003cp\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\u003c/p\u003e\u003cul\u003e\u003cli\u003e0 = O\u003c/li\u003e\u003cli\u003e1 = I\u003c/li\u003e\u003cli\u003e2 = Z\u003c/li\u003e\u003cli\u003e3 = E\u003c/li\u003e\u003cli\u003e4 = h\u003c/li\u003e\u003cli\u003e5 = S\u003c/li\u003e\u003cli\u003e6 = g\u003c/li\u003e\u003cli\u003e7 = L\u003c/li\u003e\u003cli\u003e8 = B\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThere are a few other options, but we'll stick with these. If the word has a trailing O, the number will need a decimal point to produce a leading zero. Write a function that takes a word (upside down) as input and returns the number entered into the calculator.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3018-calculator-spelling-numbers-to-letters\"\u003eProblem 3018\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n] = calc_spell_num(word)\r\n\r\nn = str2num(word);\r\n\r\nend\r\n","test_suite":"%%\r\nn = 35007;\r\nword = 'LOOSE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 77345;\r\nword = 'ShELL';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 36138;\r\nword = 'BEIgE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 378806;\r\nword = 'gOBBLE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 376006;\r\nword = 'gOOgLE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 57738461375;\r\nword = 'SLEIghBELLS';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 0.7734;\r\nword = 'hELLO';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 53045;\r\nword = 'ShOES';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 771;\r\nword = 'ILL';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 345;\r\nword = 'ShE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 7735;\r\nword = 'SELL';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nind = randi(4);\r\nn_arr = [36138 707 7714 57738];\r\nn = n_arr(ind);\r\nword_arr = {'BEIgE','LOL','hILL','BELLS'};\r\nword = word_arr{ind};\r\nassert(isequal(calc_spell_num(word),n))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":68,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-14T22:18:14.000Z","updated_at":"2026-03-23T20:41:48.000Z","published_at":"2015-02-14T22:18:14.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e0 = O\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1 = I\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2 = Z\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e3 = E\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e4 = h\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e5 = S\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e6 = g\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e7 = L\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e8 = B\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThere are a few other options, but we'll stick with these. If the word has a trailing O, the number will need a decimal point to produce a leading zero. Write a function that takes a word (upside down) as input and returns the number entered into the calculator.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3018-calculator-spelling-numbers-to-letters\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3018\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3051,"title":"Scrabble Scores - 6","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you will be provided with a character matrix representing a completed game of Scrabble. Write a function to calculate and return the total score for the entire board. Don't worry about double counting of letters or words due to tile placement—that will come in a subsequent problem. As an example, suppose you are given the following board (this is test case 1):\r\n\r\n   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere   \r\n\r\nthe word cat scores 3+1+1 = 5, poet scores 3+1+1+1 = 6, there scores 1+4+1+1+1 = 8. The remaining letters (itc, p, and l) score 1+1+3, 3, and 1 which total 9 all together (since we're not double counting letters yet). The sum total is 5+6+8+9 = 28.\r\n\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 5 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5 Multiplayer word-set scoring\u003e. Next problem: 7 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7 Multiplayer board scoring\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a character matrix representing a completed game of Scrabble. Write a function to calculate and return the total score for the entire board. Don't worry about double counting of letters or words due to tile placement—that will come in a subsequent problem. As an example, suppose you are given the following board (this is test case 1):\u003c/p\u003e\u003cpre\u003e   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere   \u003c/pre\u003e\u003cp\u003ethe word cat scores 3+1+1 = 5, poet scores 3+1+1+1 = 6, there scores 1+4+1+1+1 = 8. The remaining letters (itc, p, and l) score 1+1+3, 3, and 1 which total 9 all together (since we're not double counting letters yet). The sum total is 5+6+8+9 = 28.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 5 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5\"\u003eMultiplayer word-set scoring\u003c/a\u003e. Next problem: 7 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7\"\u003eMultiplayer board scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_6(board)\r\n\r\nscore = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nboard = [\r\n\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   ';\r\n];\r\nscore = 28;\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%%\r\nboard = [\r\n\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    ';\r\n];\r\nscore = 51;\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' what   y ';\r\n'    h  do ';\r\n'  this  um';\r\n' l  n    a';\r\n' of keen t';\r\n' o   e   l';\r\n' problem a';\r\n'      noob';\r\n];\r\nscore = 72;\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n' e    it l';\r\n' e    v  i';\r\n' please  k';\r\n'      node';\r\n];\r\nscore = 56;\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%%\r\nboard = [\r\n\r\n'c    flummoxes zither';\r\n'al    o      e e    e';\r\n'ba  hunting  eerie  b';\r\n'ab  a g   e    o    e';\r\n'lo  n     m g       l';\r\n' r  g      responses ';\r\n'random      n    u u ';\r\n' t  v   c  below p r ';\r\n'convention  r    e f ';\r\n' r  r   n   a   areas';\r\n' y      v c t    i c ';\r\n'   o  philosophy o em';\r\n'travel  n n r    r  e';\r\n'   e    c t         e';\r\n' word   i a    writer';\r\n'   t    n c    o    l';\r\n'p fortnight   rock  y';\r\n'i  n            h    ';\r\n'novelty m concatenate';\r\n'c e  o  a    a  s   g';\r\n'heterogeneousness   g';\r\n];\r\nscore = 364;\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\ncase 1\r\nboard = [\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   '];\r\nscore = 28;\r\ncase 2\r\nboard = [\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    '];\r\nscore = 51;\r\ncase 3\r\nboard = [\r\n' what   y ';\r\n'  e h  do ';\r\n'  this  um';\r\n' of n    a';\r\n'    keen t';\r\n'     e   l';\r\n' problem a';\r\n'      noob'];\r\nscore = 71;\r\ncase 4\r\nboard = [\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n'      it l';\r\n'      v  i';\r\n' please  k';\r\n'      node'];\r\nscore = 54;\r\nend\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%% anti-cheating test case (again)\r\nind = randi(4);\r\nswitch ind\r\ncase 1\r\nboard = [\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   '];\r\nscore = 28;\r\ncase 2\r\nboard = [\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    '];\r\nscore = 51;\r\ncase 3\r\nboard = [\r\n' what   y ';\r\n'  e h  do ';\r\n'  this  um';\r\n' of n    a';\r\n'    keen t';\r\n'     e   l';\r\n' problem a';\r\n'      noob'];\r\nscore = 71;\r\ncase 4\r\nboard = [\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n'      it l';\r\n'      v  i';\r\n' please  k';\r\n'      node'];\r\nscore = 54;\r\nend\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%% anti-cheating test case (and a third time, to lower the chance of getting lucky)\r\nind = randi(4);\r\nswitch ind\r\ncase 1\r\nboard = [\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   '];\r\nscore = 28;\r\ncase 2\r\nboard = [\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    '];\r\nscore = 51;\r\ncase 3\r\nboard = [\r\n' what   y ';\r\n'  e h  do ';\r\n'  this  um';\r\n' of n    a';\r\n'    keen t';\r\n'     e   l';\r\n' problem a';\r\n'      noob'];\r\nscore = 71;\r\ncase 4\r\nboard = [\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n'      it l';\r\n'      v  i';\r\n' please  k';\r\n'      node'];\r\nscore = 54;\r\nend\r\nassert(isequal(scrabble_scores_6(board),score))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":34,"test_suite_updated_at":"2015-02-28T06:29:28.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-02-28T04:41:43.000Z","updated_at":"2026-04-02T20:14:54.000Z","published_at":"2015-02-28T04:41:43.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a character matrix representing a completed game of Scrabble. Write a function to calculate and return the total score for the entire board. Don't worry about double counting of letters or words due to tile placement—that will come in a subsequent problem. As an example, suppose you are given the following board (this is test case 1):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   cat  \\n i  p   \\n t  poet\\n c  l   \\nthere]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethe word cat scores 3+1+1 = 5, poet scores 3+1+1+1 = 6, there scores 1+4+1+1+1 = 8. The remaining letters (itc, p, and l) score 1+1+3, 3, and 1 which total 9 all together (since we're not double counting letters yet). The sum total is 5+6+8+9 = 28.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 5 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer word-set scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 7 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer board scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3082,"title":"Scrabble Scores - 10","description":"This problem is very similar to the previous problem. Here, you are provided a letter of an existing word on the board from which you will play a word. The letter can reside anywhere (first to last) within the word you are playing. Write a function to find the highest scoring word, provided the letter you are building off of and the letters on your tray.\r\n\r\nRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the starting letter and the letters on your tray. 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).\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 9 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9 Word score optimization (fixed first letter)\u003e. Next problem: 11 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11 Word score optimization (known letter) \u0026 multipliers\u003e.","description_html":"\u003cp\u003eThis problem is very similar to the previous problem. Here, you are provided a letter of an existing word on the board from which you will play a word. The letter can reside anywhere (first to last) within the word you are playing. Write a function to find the highest scoring word, provided the letter you are building off of and the letters on your tray.\u003c/p\u003e\u003cp\u003eRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the starting letter and the letters on your tray. 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).\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 9 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9\"\u003eWord score optimization (fixed first letter)\u003c/a\u003e. Next problem: 11 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\"\u003eWord score optimization (known letter) \u0026 multipliers\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score,max_word] = scrabble_scores_10(words,existing_letter)\r\n\r\nscore = 0;\r\nmax_word = {''};\r\n\r\nend\r\n","test_suite":"%\r\nexisting_letter = 's'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nmax_score_corr = 12;\r\nmax_word_corr = {'atheism','hamlets'};\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nexisting_letter = 't'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\nmax_score_corr = 8;\r\nmax_word_corr = {'lentoid','tendril','trindle'};\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nexisting_letter = 'n'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\nmax_score_corr = 14;\r\nmax_word_corr = {'axmen'};\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nexisting_letter = 'z'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'aehcmdi'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\nmax_score_corr = 19;\r\nmax_word_corr = {'zaideh'};\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\texisting_letter = 's';\r\n\t\twords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'atheism','hamlets'};\r\n\tcase 2\r\n\t\texisting_letter = 't';\r\n\t\twords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\tmax_score_corr = 8;\r\n\t\tmax_word_corr = {'lentoid','tendril','trindle'};\r\n\tcase 3\r\n\t\texisting_letter = 'n';\r\n\t\twords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\n\t\tmax_score_corr = 14;\r\n\t\tmax_word_corr = {'axmen'};\r\n\tcase 4\r\n\t\texisting_letter = 'z';\r\n\t\twords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\n\t\tmax_score_corr = 19;\r\n\t\tmax_word_corr = {'zaideh'};\r\nend\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\texisting_letter = 's';\r\n\t\twords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'atheism','hamlets'};\r\n\tcase 2\r\n\t\texisting_letter = 't';\r\n\t\twords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\tmax_score_corr = 8;\r\n\t\tmax_word_corr = {'lentoid','tendril','trindle'};\r\n\tcase 3\r\n\t\texisting_letter = 'n';\r\n\t\twords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\n\t\tmax_score_corr = 14;\r\n\t\tmax_word_corr = {'axmen'};\r\n\tcase 4\r\n\t\texisting_letter = 'z';\r\n\t\twords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\n\t\tmax_score_corr = 19;\r\n\t\tmax_word_corr = {'zaideh'};\r\nend\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":7,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":"2015-03-17T13:21:23.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-14T18:30:00.000Z","updated_at":"2026-04-02T20:19:50.000Z","published_at":"2015-03-14T18:30:35.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is very similar to the previous problem. Here, you are provided a letter of an existing word on the board from which you will play a word. The letter can reside anywhere (first to last) within the word you are playing. Write a function to find the highest scoring word, provided the letter you are building off of and the letters on your tray.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the starting letter and the letters on your tray. 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).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 9 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (fixed first letter)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 11 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (known letter) \u0026amp; multipliers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3050,"title":"Scrabble Scores - 5","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you will be provided with a set of words for each player in a game of Scrabble. The number of players may vary from two to four. The word set for each player will be provided in a cell array of strings; you'll need to use nargin and varargin to read in varying numbers of cell arrays for each test case. Write a function to calculate and return the total score for each player in a vector equal in length to the number of players.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 4 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4 Word-set multiplier scoring\u003e. Next problem: 6 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6 Board scoring\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a set of words for each player in a game of Scrabble. The number of players may vary from two to four. The word set for each player will be provided in a cell array of strings; you'll need to use nargin and varargin to read in varying numbers of cell arrays for each test case. Write a function to calculate and return the total score for each player in a vector equal in length to the number of players.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 4 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\"\u003eWord-set multiplier scoring\u003c/a\u003e. Next problem: 6 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6\"\u003eBoard scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_5(varargin)\r\n\r\nscore = zeros(1,nargin);\r\n\r\nend\r\n","test_suite":"%%\r\nwords1 = {'hello','there','fellow','matlab','users'};\r\nwords2 = {'what','do','you','think','of','this','problem'};\r\nwords3 = {'if','you','like','it','please','give','it','a','like'};\r\nscore = [43 56 48];\r\nassert(isequal(scrabble_scores_5(words1,words2,words3),score))\r\n\r\n%%\r\nwords1 = {'zither','quandry','flummox','wealthy','amalgam'};\r\nwords2 = {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\nwords3 = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\nwords4 = {'perspicacious','yes','zero','quizzical','no'};\r\nscore = [87 94 70 80];\r\nassert(isequal(scrabble_scores_5(words1,words2,words3,words4),score))\r\n\r\n%%\r\nwords1 = {'one','two','three','four','five'};\r\nwords2 = {'six','seven','eight','nine','ten'};\r\nscore = [34 34];\r\nassert(isequal(scrabble_scores_5(words1,words2),score))\r\n\r\n%%\r\nwords1 = {'random','word','generator','responses','below'};\r\nwords2 = {'contact','laboratory','overtone','writer','philosophy'};\r\nwords3 = {'hunting','convention','surface','superior','travel'};\r\nwords4 = {'convincing','hangover','fortnight','long','novelty'};\r\nscore = [48 69 57 67];\r\nassert(isequal(scrabble_scores_5(words1,words2,words3,words4),score))\r\n\r\n%%\r\nwords = { {'random','word','generator','responses','below'};\r\n {'contact','laboratory','overtone','writer','philosophy'};\r\n {'hunting','convention','surface','superior','travel'};\r\n {'convincing','hangover','fortnight','long','novelty'}; };\r\nscore = [48 69 57 67];\r\nind1 = randi(4);\r\nind2 = randi(4);\r\nassert(isequal(scrabble_scores_5(words{ind1},words{ind2}),[score(ind1) score(ind2)]))\r\n\r\n%%\r\nwords = { {'zither','quandry','flummox','wealthy','amalgam'};\r\n {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\n {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\n {'perspicacious','yes','zero','quizzical','no'}; };\r\nscore = [87 94 70 80];\r\nind1 = randi(4);\r\nind2 = randi(4);\r\nassert(isequal(scrabble_scores_5(words{ind1},words{ind2}),[score(ind1) score(ind2)]))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":36,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":40,"created_at":"2015-02-28T03:40:58.000Z","updated_at":"2026-04-02T20:13:53.000Z","published_at":"2015-02-28T03:40:58.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a set of words for each player in a game of Scrabble. The number of players may vary from two to four. The word set for each player will be provided in a cell array of strings; you'll need to use nargin and varargin to read in varying numbers of cell arrays for each test case. Write a function to calculate and return the total score for each player in a vector equal in length to the number of players.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 4 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord-set multiplier scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 6 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eBoard scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3062,"title":"Scrabble Scores - 9","description":"After developing a sophisticated Scrabble scoring routine, it's time to write an optimization routine for single-word scoring. The point distribution for English is provided \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e.\r\n\r\nFor this problem, you are provided the starting letter (from an existing word on the board) from which you will play a word. For this problem, we'll assume that that's the first letter of your new word.\r\n\r\nRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the letters on your tray. Write a function to determine which word would provide the highest score. Also, provide the word(s) that achieve that score in a cell array. See the test suite for examples.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 8 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8 Multiplayer multiplier board scoring\u003e. Next problem: 10 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10 Word score optimization (given letter)\u003e.","description_html":"\u003cp\u003eAfter developing a sophisticated Scrabble scoring routine, it's time to write an optimization routine for single-word scoring. The point distribution for English is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eFor this problem, you are provided the starting letter (from an existing word on the board) from which you will play a word. For this problem, we'll assume that that's the first letter of your new word.\u003c/p\u003e\u003cp\u003eRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the letters on your tray. Write a function to determine which word would provide the highest score. Also, provide the word(s) that achieve that score in a cell array. See the test suite for examples.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 8 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8\"\u003eMultiplayer multiplier board scoring\u003c/a\u003e. Next problem: 10 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\"\u003eWord score optimization (given letter)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [max_score,max_word] = scrabble_scores_9(words,first_letter)\r\n\r\nmax_score = 0;\r\nmax_word = '';\r\n\r\nend\r\n","test_suite":"%%\r\nfirst_letter = 's'; %the word must start with this letter, which is in an already played word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix)\r\nwords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nmax_score_corr = 10;\r\nmax_word_corr = {'shame','smith'};\r\n[max_score,max_word] = scrabble_scores_9(words,first_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_letter = 't'; %the word must start with this letter, which is in an already played word\r\ntray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix)\r\nwords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\nmax_score_corr = 8;\r\nmax_word_corr = {'tendril','trindle'};\r\n[max_score,max_word] = scrabble_scores_9(words,first_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_letter = 'n'; %the word must start with this letter, which is in an already played word\r\ntray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix)\r\nwords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\nmax_score_corr = 8;\r\nmax_word_corr = {'named','nomad','novae'};\r\n[max_score,max_word] = scrabble_scores_9(words,first_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_letter = 'z'; %the word must start with this letter, which is in an already played word\r\ntray_letters = 'aehcmdi'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix)\r\nwords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\nmax_score_corr = 19;\r\nmax_word_corr = {'zaideh'};\r\n[max_score,max_word] = scrabble_scores_9(words,first_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tfirst_letter = 's';\r\n\t\twords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\n\t\tmax_score_corr = 10;\r\n\t\tmax_word_corr = {'shame','smith'};\r\n\tcase 2\r\n\t\tfirst_letter = 't';\r\n\t\twords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\tmax_score_corr = 8;\r\n\t\tmax_word_corr = {'tendril','trindle'};\r\n\tcase 3\r\n\t\tfirst_letter = 'n';\r\n\t\twords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\n\t\tmax_score_corr = 8;\r\n\t\tmax_word_corr = {'named','nomad','novae'};\r\n\tcase 4\r\n\t\tfirst_letter = 'z';\r\n\t\twords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\n\t\tmax_score_corr = 19;\r\n\t\tmax_word_corr = {'zaideh'};\r\nend\r\n[max_score,max_word] = scrabble_scores_9(words,first_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-04T02:02:45.000Z","updated_at":"2026-04-02T20:19:03.000Z","published_at":"2015-03-04T02:02:45.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAfter developing a sophisticated Scrabble scoring routine, it's time to write an optimization routine for single-word scoring. The point distribution for English is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you are provided the starting letter (from an existing word on the board) from which you will play a word. For this problem, we'll assume that that's the first letter of your new word.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the letters on your tray. Write a function to determine which word would provide the highest score. Also, provide the word(s) that achieve that score in a cell array. See the test suite for examples.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 8 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer multiplier board scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 10 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (given letter)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44816,"title":"Word Distance - Average Sort","description":"Based on the method of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44815-word-distance-sum this problem\u003e, write a function to calculate the letter distance for a set of words and then return the sorted set of words based on their distances, in ascending order. However, their distances will now be normalized by the number of characters in each word. For example, if \r\n\r\n str_arr = {'jazz','cab','tree'}\r\n\r\nthen \r\n\r\n d = [(9+25+0)/4, (2+1)/3, (2+13+0)/4] = [34/4, 3/3, 15/4] = [8.5, 1, 3.75]\r\n\r\nwhich would result in the following sorted order:\r\n\r\n str_arr_sort = {'cab','tree','jazz'}\r\n\r\nRemember that the method is case insensitive. See the test suite for examples.","description_html":"\u003cp\u003eBased on the method of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44815-word-distance-sum\"\u003ethis problem\u003c/a\u003e, write a function to calculate the letter distance for a set of words and then return the sorted set of words based on their distances, in ascending order. However, their distances will now be normalized by the number of characters in each word. For example, if\u003c/p\u003e\u003cpre\u003e str_arr = {'jazz','cab','tree'}\u003c/pre\u003e\u003cp\u003ethen\u003c/p\u003e\u003cpre\u003e d = [(9+25+0)/4, (2+1)/3, (2+13+0)/4] = [34/4, 3/3, 15/4] = [8.5, 1, 3.75]\u003c/pre\u003e\u003cp\u003ewhich would result in the following sorted order:\u003c/p\u003e\u003cpre\u003e str_arr_sort = {'cab','tree','jazz'}\u003c/pre\u003e\u003cp\u003eRemember that the method is case insensitive. See the test suite for examples.\u003c/p\u003e","function_template":"function d = word_distance_sort(str_arr)\r\n d = 1;\r\nend","test_suite":"%%\r\nassert(isequal(word_distance_sort({'jazz','cab','tree'}),{'cab','tree','jazz'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'first','second','third'}),{'first','second','third'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'the','longest','words','supercede','some','of','the','shortest'}), ...\r\n\t{'some','longest','of','the','the','supercede','shortest','words'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'one','TWO','Three','FouR','fiVe','six','sEvEn','EiGHt','NINe','ten'}), ...\r\n\t{'one','TWO','EiGHt','FouR','NINe','Three','ten','fiVe','six','sEvEn'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'Why','is','it','that','this','does','not','work','as','expected'}), ...\r\n\t{'not','work','is','it','this','does','as','expected','that','Why'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'set','of','very','short','words','for','this','test','case'}), ...\r\n\t{'for','of','short','this','test','words','case','very','set'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'iron','zinc','carbon','molybdenum','praseodymium','silicon'}), ...\r\n\t{'iron','silicon','molybdenum','carbon','zinc','praseodymium'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'crazier','craziest','crazy'}), ...\r\n\t{'crazy','craziest','crazier'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'this','test','case','with','only','four','each','word'}), ...\r\n\t{'each','only','four','this','word','test','case','with'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'largest','smallest','sourest','sweetest'}), ...\r\n\t{'sourest','smallest','largest','sweetest'}))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":15,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":65,"created_at":"2019-01-02T15:43:24.000Z","updated_at":"2025-11-21T14:57:55.000Z","published_at":"2019-01-09T15:06:52.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased on the method of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44815-word-distance-sum\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ethis problem\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, write a function to calculate the letter distance for a set of words and then return the sorted set of words based on their distances, in ascending order. However, their distances will now be normalized by the number of characters in each word. For example, if\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ str_arr = {'jazz','cab','tree'}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ d = [(9+25+0)/4, (2+1)/3, (2+13+0)/4] = [34/4, 3/3, 15/4] = [8.5, 1, 3.75]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhich would result in the following sorted order:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ str_arr_sort = {'cab','tree','jazz'}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember that the method is case insensitive. See the test suite for examples.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3049,"title":"Scrabble Scores - 4","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings; the bonus squares will be provided in a two-level cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\r\n\r\n* 'DL' = double letter\r\n* 'DW' = double word\r\n* 'TL' = triple letter\r\n* 'TW' = triple word\r\n* 'QL' = quadruple letter\r\n* 'QW' = quadruple word\r\n\r\nFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026 TW = *6).\r\n\r\nAs an example, if the word were 'matlab' and the multiplier cell array was \r\n\r\n  {'','DW','','','','DL'}\r\n\r\n\r\nthen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\r\n\r\nThis is an old version of problem 4 in this series. It has been revised and is available here: \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4 Word-set multiplier scoring\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings; the bonus squares will be provided in a two-level cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\u003c/p\u003e\u003cul\u003e\u003cli\u003e'DL' = double letter\u003c/li\u003e\u003cli\u003e'DW' = double word\u003c/li\u003e\u003cli\u003e'TL' = triple letter\u003c/li\u003e\u003cli\u003e'TW' = triple word\u003c/li\u003e\u003cli\u003e'QL' = quadruple letter\u003c/li\u003e\u003cli\u003e'QW' = quadruple word\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026 TW = *6).\u003c/p\u003e\u003cp\u003eAs an example, if the word were 'matlab' and the multiplier cell array was\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e{'','DW','','','','DL'}\r\n\u003c/pre\u003e\u003cp\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\u003c/p\u003e\u003cp\u003eThis is an old version of problem 4 in this series. It has been revised and is available here: \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\"\u003eWord-set multiplier scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_4(words,mult)\r\n\r\nscore = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nwords = {'hello','there','fellow','matlab','users'};\r\nmult = {{'DW','','','','DL'} {'DW','','','','DL'} {'','DW','','','','DL'} {'','DW','','','','DL'} {'DW','','','','DL'}};\r\nscore = 106;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%%\r\nwords = {'what','do','you','think','of','this','problem'};\r\nmult = {{'','DW','',''}; {'',''}; {'','DW',''}; {'','DW','','','TL'}; {'',''}; {'','DW','',''}; {'TL','','','DW','','','TL'}};\r\nscore = 148;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%%\r\nwords = {'if','you','like','it','please','give','it','a','like'};\r\nmult = {{'','DW'}; {'','','QW'}; {'','DW','',''}; {'',''}; {'','DW','','','TL',''}; {'','DW','',''}; {'TL',''}; {''}; {'DW','','','TL'}};\r\nscore = 113;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%%\r\nwords = {'zither','quandry','flummox','wealthy','amalgam'};\r\nmult = {{'','DW','','','','DW'}; {'QL','','','','','DW',''}; {'','DW','','','','DW',''}; {'','DW','','','','DW',''}; {'','DW','','','','DW',''}; };\r\nscore = 368;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%%\r\nwords = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\nmult = {{'TL','','','','TL','','','','TW','','','','QW'}; {'','','','TL','','','','TW','','','','QW'}; {'TL','','','','TL','','','','TW','',''}; {'TL','','','','TL',''}; {'',''}; };\r\nscore = 690;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%%\r\nwords = {'perspicacious','yes','zero','quizzical','no'};\r\nmult = {{'TL','','','','TL','','','','TW','','','','QW'}; {'','',''}; {'TL','','',''}; {'TL','','','','TL','','','TW',''}; {'',''}; };\r\nscore = 671;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%% pangram test to help ensure letters scores are correctly assigned\r\nwords = {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\nmult = {{'TL','',''}; {'','TL','','',''}; {'TW','','','','QW'}; {'','',''}; {'TL','','','','QL'}; {'TL','','',''}; {'TL'}; {'','','TW',''}; {'','','QW'}; };\r\nscore = 278;\r\nassert(isequal(scrabble_scores_4(words,mult),score))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":15,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-02-28T03:14:55.000Z","updated_at":"2025-11-01T19:19:19.000Z","published_at":"2015-02-28T03:14:55.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings; the bonus squares will be provided in a two-level cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'DL' = double letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'DW' = double word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'TL' = triple letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'TW' = triple word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'QL' = quadruple letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'QW' = quadruple word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026amp; TW =\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e *\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e6).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, if the word were 'matlab' and the multiplier cell array was\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[{'','DW','','','','DL'}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis is an old version of problem 4 in this series. It has been revised and is available here:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord-set multiplier scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3048,"title":"Scrabble Scores - 3","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you will be provided with a word and the accompanying bonus squares that the word might have covered (in a cell array of strings). Write a function to calculate the total score for the word using the multipliers. The multipliers are as follows:\r\n\r\n* 'DL' = double letter\r\n* 'DW' = double word\r\n* 'TL' = triple letter\r\n* 'TW' = triple word\r\n* 'QL' = quadruple letter\r\n* 'QW' = quadruple word\r\n\r\nFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026 TW = *6).\r\n\r\nAs an example, if the word were 'matlab' and the multiplier cell array was \r\n\r\n  {'','DW','','','','DL'}\r\n\r\n\r\nthen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 2 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3047-scrabble-scores-2 Word-set scoring\u003e. Next problem: 4 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4 Word-set multiplier scoring\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a word and the accompanying bonus squares that the word might have covered (in a cell array of strings). Write a function to calculate the total score for the word using the multipliers. The multipliers are as follows:\u003c/p\u003e\u003cul\u003e\u003cli\u003e'DL' = double letter\u003c/li\u003e\u003cli\u003e'DW' = double word\u003c/li\u003e\u003cli\u003e'TL' = triple letter\u003c/li\u003e\u003cli\u003e'TW' = triple word\u003c/li\u003e\u003cli\u003e'QL' = quadruple letter\u003c/li\u003e\u003cli\u003e'QW' = quadruple word\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026 TW = *6).\u003c/p\u003e\u003cp\u003eAs an example, if the word were 'matlab' and the multiplier cell array was\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e{'','DW','','','','DL'}\r\n\u003c/pre\u003e\u003cp\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 2 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3047-scrabble-scores-2\"\u003eWord-set scoring\u003c/a\u003e. Next problem: 4 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\"\u003eWord-set multiplier scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_3(word,mult)\r\n\r\nscore = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nword = 'matlab';\r\nmult = {'','DW','','','','DL'};\r\nscore = 26;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = 'problem';\r\nmult = {'','','','','','',''};\r\nscore = 13;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = 'zither';\r\nmult = {'','DW','','','','DW'};\r\nscore = 72;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = 'quandry';\r\nmult = {'TL','','','','TL','',''};\r\nscore = 44;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = 'concatenates';\r\nmult = {'TW','','','DL','','','','TW','','','','DL'};\r\nscore = 180;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = 'heterogeneousness';\r\nmult = {'QW','','','DL','','','','TW','','','DL','','','TW','','',''};\r\nscore = 828;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = {'hello','donut','cheat','shape','quote'};\r\nmult = {'QW','','','DL',''};\r\nscore = [36 28 44 52 60];\r\nind = randi(5);\r\nassert(isequal(scrabble_scores_3(word{ind},mult),score(ind)))\r\n\r\n%%\r\nword = {'hello','donut','cheat','shape','quote'};\r\nmult = {'QL','','','','DW'};\r\nscore = [40 24 38 26 88];\r\nind = randi(5);\r\nassert(isequal(scrabble_scores_3(word{ind},mult),score(ind)))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":40,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":40,"created_at":"2015-02-26T04:46:46.000Z","updated_at":"2026-04-02T20:11:50.000Z","published_at":"2015-02-26T04:46:46.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a word and the accompanying bonus squares that the word might have covered (in a cell array of strings). Write a function to calculate the total score for the word using the multipliers. The multipliers are as follows:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'DL' = double letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'DW' = double word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'TL' = triple letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'TW' = triple word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'QL' = quadruple letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'QW' = quadruple word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026amp; TW =\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e *\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e6).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, if the word were 'matlab' and the multiplier cell array was\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[{'','DW','','','','DL'}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 2 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3047-scrabble-scores-2\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord-set scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 4 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord-set multiplier scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3081,"title":"Scrabble Scores - 4","description":"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.)\r\n\r\nFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\r\n\r\n * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\r\n\r\nFor those not familiar with quadruple word (Q) and quadruple letter (q), those were introduced in Super Scrabble. Also, remember that the d, t, and q multipliers take effect before the D, T, and Q multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., D \u0026 T = *6).\r\n\r\nAs an example, if the word were 'matlab' and the multiplier string array was\r\n\r\n  [' ','D',' ',' ',' ','d'] (or ' D   d')\r\n\r\nthen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 3 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3 Single-word multiplier scoring\u003e. Next problem: 5 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5 Multiplayer word-set scoring\u003e.","description_html":"\u003cp\u003eThis 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.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\u003c/p\u003e\u003cpre\u003e * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\u003c/pre\u003e\u003cp\u003eFor those not familiar with quadruple word (Q) and quadruple letter (q), those were introduced in Super Scrabble. Also, remember that the d, t, and q multipliers take effect before the D, T, and Q multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., D \u0026 T = *6).\u003c/p\u003e\u003cp\u003eAs an example, if the word were 'matlab' and the multiplier string array was\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e[' ','D',' ',' ',' ','d'] (or ' D   d')\r\n\u003c/pre\u003e\u003cp\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 3 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3\"\u003eSingle-word multiplier scoring\u003c/a\u003e. Next problem: 5 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5\"\u003eMultiplayer word-set scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_4_rev(words,mult)\r\n\r\nscore = 0;\r\n\r\nend\r\n","test_suite":"%\r\nwords = {'hello','there','fellow','matlab','users'};\r\nmult = {'D   d','D   d',' D   d',' D   d','D   d'};\r\nscore = 106;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%%\r\nwords = {'what','do','you','think','of','this','problem'};\r\nmult = {' D  ','  ',' D ',' D  t','  ',' D  ','t  D  t'};\r\nscore = 148;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%%\r\nwords = {'if','you','like','it','please','give','it','a','like'};\r\nmult = {' D','  Q',' D  ','  ',' D  t ',' D  ','t ',' ','D  t'};\r\nscore = 113;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%%\r\nwords = {'zither','quandry','flummox','wealthy','amalgam'};\r\nmult = {' D   D','q    D ',' D   D ',' D   D ',' D   D '};\r\nscore = 368;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%%\r\nwords = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\nmult = {'t   t   T   Q','   t   T   Q','t   t   T  ','t   t ','  '};\r\nscore = 690;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%%\r\nwords = {'perspicacious','yes','zero','quizzical','no'};\r\nmult = {'t   t   T   Q','   ','t   ','t   t  T ','  '};\r\nscore = 671;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%% pangram test to help ensure letters scores are correctly assigned\r\nwords = {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\nmult = {'t  ',' t   ','T   Q','   ','t   q','t   ','t','  T ','  Q'};\r\nscore = 278;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%% anti-cheating case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\twords = {'hello','there','fellow','matlab','users'};\r\n\t\tmult = {'D   d','D   d',' D   d',' D   d','D   d'};\r\n\t\tscore = 106;\r\n\tcase 2\r\n\t\twords = {'if','you','like','it','please','give','it','a','like'};\r\n\t\tmult = {' D','  Q',' D  ','  ',' D  t ',' D  ','t ',' ','D  t'};\r\n\t\tscore = 113;\r\n\tcase 3\r\n\t\twords = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\n\t\tmult = {'t   t   T   Q','   t   T   Q','t   t   T  ','t   t ','  '};\r\n\t\tscore = 690;\r\n\tcase 4\r\n\t\twords = {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\n\t\tmult = {'t  ',' t   ','T   Q','   ','t   q','t   ','t','  T ','  Q'};\r\n\t\tscore = 278;\r\nend\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%% anti-cheating case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\twords = {'what','do','you','think','of','this','problem'};\r\n\t\tmult = {' D  ','  ',' D ',' D  t','  ',' D  ','t  D  t'};\r\n\t\tscore = 148;\r\n\tcase 2\r\n\t\twords = {'perspicacious','yes','zero','quizzical','no'};\r\n\t\tmult = {'t   t   T   Q','   ','t   ','t   t  T ','  '};\r\n\t\tscore = 671;\r\n\tcase 3\r\n\t\twords = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\n\t\tmult = {'t   t   T   Q','   t   T   Q','t   t   T  ','t   t ','  '};\r\n\t\tscore = 690;\r\n\tcase 4\r\n\t\twords = {'zither','quandry','flummox','wealthy','amalgam'};\r\n\t\tmult = {' D   D','q    D ',' D   D ',' D   D ',' D   D '};\r\n\t\tscore = 368;\r\nend\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":34,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-14T18:10:41.000Z","updated_at":"2026-04-02T20:12:58.000Z","published_at":"2015-03-14T18:10:41.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis 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.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ * D: double word\\n * T: triple word\\n * Q: quadruple word\\n * d: double letter\\n * t: triple letter\\n * q: quadruple letter]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor those not familiar with quadruple word (Q) and quadruple letter (q), those were introduced in Super Scrabble. Also, remember that the d, t, and q multipliers take effect before the D, T, and Q multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., D \u0026amp; T =\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e *\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e6).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, if the word were 'matlab' and the multiplier string array was\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[[' ','D',' ',' ',' ','d'] (or ' D   d')]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 3 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSingle-word multiplier scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 5 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer word-set scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":53960,"title":"Wordle","description":"Wordle is an english game where you need to guess a 5 letter word. For each guess you'll receive a feedback for the placement of each letter. If a letter is in the correct spot it will show as green, if a letter is in the word, but in the wrong spot it will show as yellow and if the letter is not present in the word it will show as black.\r\nFor this problem your inputs will be the target word and a guess, the output should be a vector corresponding to the guess word where there should be a -1 if the letter is not present in the target word, a 0 if the letter is present in the target word, but at the wrong spot, and a 1 if the letter is in the correct spot.\r\n\r\nExample:\r\nTarget Word: 'thing'\r\nGuess Word: 'write'\r\nOutput: [-1 -1 1 0 -1]\r\nAll inputs will be lower case and contain 5 letters.\r\nIf a letter appears more than once in the guess and only once in the target word then it should be considered correct only once. consider the correct letter the one in the correct spot if any, else the first occurence of the letter should be considered (see test cases 2,3, and 4 for examples)","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 387px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 193.5px; transform-origin: 407px 193.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://www.powerlanguage.co.uk/wordle/\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWordle\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e is an english game where you need to guess a 5 letter word. For each guess you'll receive a feedback for the placement of each letter. If a letter is in the correct spot it will show as green, if a letter is in the word, but in the wrong spot it will show as yellow and if the letter is not present in the word it will show as black.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor this problem your inputs will be the target word and a guess, the output should be a vector corresponding to the guess word where there should be a -1 if the letter is not present in the target word, a 0 if the letter is present in the target word, but at the wrong spot, and a 1 if the letter is in the correct spot.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eTarget Word: 'thing'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eGuess Word: 'write'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eOutput: [-1 -1 1 0 -1]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eAll inputs will be lower case and contain 5 letters.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eIf a letter appears more than once in the guess and only once in the target word then it should be considered correct only once. consider the correct letter the one in the correct spot if any, else the first occurence of the letter should be considered (see test cases 2,3, and 4 for examples)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = wordle(target,guess)\r\n  y =[0 0 0 0 0];\r\nend","test_suite":"%%\r\ntarget = 'prick';\r\nguess = 'thing';\r\ny_correct = [-1 -1 1 -1 -1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'carts';\r\nguess = 'sssss';\r\ny_correct = [-1 -1 -1 -1 1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'parts';\r\nguess = 'ssssp';\r\ny_correct = [0 -1 -1 -1 0];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'sides';\r\nguess = 'ksssk';\r\ny_correct = [-1 0 0 -1 -1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'write';\r\nguess = 'price';\r\ny_correct = [-1 1 1 -1 1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'heart';\r\nguess = 'lists';\r\ny_correct = [-1 -1 -1 0 -1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'blues';\r\nguess = 'purge';\r\ny_correct = [-1 0 -1 -1 0];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'perky';\r\nguess = 'pluck';\r\ny_correct = [1 -1 -1 -1 0];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'perky';\r\nguess = 'axiom';\r\ny_correct = [-1 -1 -1 -1 -1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'perky';\r\nguess = 'perks';\r\ny_correct = [1 1 1 1 -1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'mount';\r\nguess = 'mount';\r\ny_correct = [1 1 1 1 1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":1766515,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":8,"test_suite_updated_at":"2022-01-28T14:57:59.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2022-01-21T15:14:48.000Z","updated_at":"2024-11-14T20:03:07.000Z","published_at":"2022-01-21T15:14:48.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.powerlanguage.co.uk/wordle/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWordle\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is an english game where you need to guess a 5 letter word. For each guess you'll receive a feedback for the placement of each letter. If a letter is in the correct spot it will show as green, if a letter is in the word, but in the wrong spot it will show as yellow and if the letter is not present in the word it will show as black.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem your inputs will be the target word and a guess, the output should be a vector corresponding to the guess word where there should be a -1 if the letter is not present in the target word, a 0 if the letter is present in the target word, but at the wrong spot, and a 1 if the letter is in the correct spot.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTarget Word: 'thing'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGuess Word: 'write'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: [-1 -1 1 0 -1]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAll inputs will be lower case and contain 5 letters.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf a letter appears more than once in the guess and only once in the target word then it should be considered correct only once. consider the correct letter the one in the correct spot if any, else the first occurence of the letter should be considered (see test cases 2,3, and 4 for examples)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44815,"title":"Word Distance - Sum","description":"Let's suppose that the distance of a word can be calculated by summing the differences between its letters, having assigned the letters of the alphabet to integers (a = 1, b = 2, ... z = 26). For example, if\r\n\r\n word = 'hello'\r\n\r\nthen the total distance would be \r\n\r\n abs(8–5) + abs(5–12) + abs(12–12) + abs(12–15) = 3 + 7 + 0 + 3 = 13.\r\n\r\nLet's also make this case insensitive (i.e., 'A' = 'a'). Write a function to return the distance for any word or set of words. See the test suite for examples.","description_html":"\u003cp\u003eLet's suppose that the distance of a word can be calculated by summing the differences between its letters, having assigned the letters of the alphabet to integers (a = 1, b = 2, ... z = 26). For example, if\u003c/p\u003e\u003cpre\u003e word = 'hello'\u003c/pre\u003e\u003cp\u003ethen the total distance would be\u003c/p\u003e\u003cpre\u003e abs(8–5) + abs(5–12) + abs(12–12) + abs(12–15) = 3 + 7 + 0 + 3 = 13.\u003c/pre\u003e\u003cp\u003eLet's also make this case insensitive (i.e., 'A' = 'a'). Write a function to return the distance for any word or set of words. See the test suite for examples.\u003c/p\u003e","function_template":"function d = word_distance_sum(str)\r\n d = 1;\r\nend","test_suite":"%%\r\nassert(isequal(word_distance_sum('hello'),13))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('Hello'),13))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('HELLO'),13))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('way'),46))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('Sway'),50))\r\n\r\n%%\r\n[d] = word_distance_sum({'hello','Sway'});\r\nassert(isequal(d(1),13))\r\nassert(isequal(d(2),50))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('Matlab'),51))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('aBCdEfghIJkLmNOPqrStUVwxyZ'),25))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('qwerty'),44))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('bead'),10))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('payday'),87))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('bookkeeper'),58))\r\n\r\n%%\r\n[d] = word_distance_sum({'one','TWO','Three','FouR','fiVe','six','sEvEn','EiGHt','NINe','ten'});\r\nassert(isequal(d(1),10))\r\nassert(isequal(d(2),11))\r\nassert(isequal(d(3),35))\r\nassert(isequal(d(4),18))\r\nassert(isequal(d(5),33))\r\nassert(isequal(d(6),25))\r\nassert(isequal(d(7),57))\r\nassert(isequal(d(8),19))\r\nassert(isequal(d(9),19))\r\nassert(isequal(d(10),24))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('crazier'),91))","published":true,"deleted":false,"likes_count":4,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":185,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":65,"created_at":"2019-01-02T14:44:50.000Z","updated_at":"2026-03-30T18:05:29.000Z","published_at":"2019-01-02T14:44:50.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eLet's suppose that the distance of a word can be calculated by summing the differences between its letters, having assigned the letters of the alphabet to integers (a = 1, b = 2, ... z = 26). For example, if\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ word = 'hello']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen the total distance would be\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ abs(8–5) + abs(5–12) + abs(12–12) + abs(12–15) = 3 + 7 + 0 + 3 = 13.]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eLet's also make this case insensitive (i.e., 'A' = 'a'). Write a function to return the distance for any word or set of words. See the test suite for examples.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3097,"title":"Scrabble Scores - 12","description":"This problem builds directly off of Scrabble Scores - 10. 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. Write a function to find the highest scoring word, provided any letter from the existing word that you are building off of and the letters on your tray.\r\nRather 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).\r\nRelated problems:\r\nPrevious problem: 11 - Word score optimization (known letter \u0026 multipliers). Next problem: 13 - Word score optimization (first word \u0026 multipliers).","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 279px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 139.5px; transform-origin: 407px 139.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 104px 8px; transform-origin: 104px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem builds directly off of\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eScrabble Scores - 10\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 209px 8px; transform-origin: 209px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. 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. Write a function to find the highest scoring word, provided any letter from the existing word that you are building off of and the letters on your tray.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 105px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 52.5px; text-align: left; transform-origin: 384px 52.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 382.5px 8px; transform-origin: 382.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eRather 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).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 57.5px 8px; transform-origin: 57.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eRelated problems:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 71px 8px; transform-origin: 71px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ePrevious problem: 11 -\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWord score optimization (known letter \u0026amp; multipliers)\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 61.5px 8px; transform-origin: 61.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Next problem: 13 -\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3098-scrabble-scores-13\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWord score optimization (first word \u0026amp; multipliers)\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [score,max_word] = scrabble_scores_12(words, first_word)\r\n\r\nscore = 0;\r\nmax_word = {''};\r\n\r\nend\r\n","test_suite":"%%\r\nfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nwords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nwords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\nwords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\nwords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nmax_score_corr = 12;\r\nmax_word_corr = {'atheism','hamlets','hematal','thalami','thermal'};\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_word = 'thinning'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\nwords{2} = {'dhole','diner','drone','eloin','enrol','helio','heron','hider','hired','holed','honed','honer','horde','idler','indol','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','rhino','riled','ronde','dehorn','dinero','heroin','hinder','hoiden','holden','holder','holier','hondle','honied','horned','indole','ironed','neroli','roiled','rondel','hordein','inholder'};\r\nwords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\nwords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\nwords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{8} = {'deign','diner','dinge','dingo','dirge','dogie','doing','drone','eloin','enrol','gelid','genro','geoid','giron','glide','goner','gored','gride','grind','groin','idler','indol','ingle','irone','liger','lined','liner','lingo','loden','lodge','login','loner','longe','nerol','ogled','ogler','oiled','oiler','olden','older','oldie','olein','oriel','redon','reign','renig','reoil','ridge','riled','ronde','dinero','dinger','dingle','doling','dongle','eloign','engild','engird','eringo','gilder','girdle','girned','glider','golden','golder','ignore','indole','ironed','legion','linger','lodger','logier','longed','longer','neroli','reding','regild','region','ridgel','ringed','roiled','rondel','eroding','glenoid','gloried','godlier','groined','ignored','lording','negroid','redoing'};\r\nmax_score_corr = 12;\r\nmax_word_corr = {'inholder'};\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_word = 'novels'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\nwords{2} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','moo','oda','ode','oma','ova','oxo','vex','voe','vox','axed','dame','demo','deva','dome','doom','dove','exam','made','mead','mode','mood','move','moxa','odea','maxed','mooed','moved'};\r\nwords{3} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vav','vex','voe','vox','axed','dame','demo','deva','dome','dove','exam','made','mead','mode','move','moxa','odea','maxed','moved'};\r\nwords{4} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dee','dev','dex','doe','dom','eme','emo','eve','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vee','vex','voe','vox','axed','dame','deem','deme','demo','deva','dome','dove','eave','exam','exed','made','mead','meed','mode','move','moxa','odea','adeem','deave','eaved','edema','evade','maxed','moved','vexed','oedema'};\r\nwords{5} = {'ad','ae','al','am','ax','da','de','do','ed','el','em','ex','la','lo','ma','me','mo','od','oe','om','ox','ado','ale','ave','avo','axe','dal','dam','del','dev','dex','doe','dol','dom','eld','elm','emo','lad','lam','lav','lax','lea','led','lev','lex','lox','mad','mae','max','med','mel','moa','mod','mol','oda','ode','old','ole','oma','ova','vex','voe','vox','alme','aloe','axed','axel','axle','dale','dame','deal','demo','deva','dole','dome','dove','exam','lade','lame','lave','lead','leva','levo','load','loam','lode','love','made','male','mead','meal','meld','mode','mola','mold','mole','move','moxa','odea','olde','olea','oval','vale','veal','vela','veld','vole','amole','axled','dolma','domal','laevo','lamed','laved','loved','loxed','maxed','medal','modal','model','moved','voled','voxel','loamed'};\r\nwords{6} = {'ad','ae','am','as','ax','da','de','do','ed','em','es','ex','ma','me','mo','od','oe','om','os','ox','so','ado','ads','ave','avo','axe','dam','das','dev','dex','doe','dom','dos','eds','emo','ems','mad','mae','mas','max','med','moa','mod','mos','oda','ode','ods','oes','oma','oms','ose','ova','sad','sae','sax','sea','sev','sex','sod','som','sox','vas','vex','voe','vox','ados','aves','avos','axed','axes','dame','dams','demo','deva','devs','does','dome','doms','dosa','dose','dove','emos','exam','made','mads','maes','mead','meds','mesa','moas','mode','mods','move','moxa','odas','odea','odes','omas','oxes','sade','same','save','seam','soda','soma','some','vase','voes','dames','demos','devas','domes','doves','exams','maxed','maxes','meads','modes','moved','moves','moxas','oaves','saved','soave','vadose','vamose','vamosed'};\r\nmax_score_corr = 16;\r\nmax_word_corr = {'vexed'};\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_word = 'zoologist'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aehcmdi'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\nwords{2} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{2} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{4} = {'aced','ache','acid','acme','ahed','ahem','aide','alec','alme','amid','amie','cade','cadi','caid','calm','came','cami','cedi','ceil','chad','chai','cham','chem','chia','chid','clad','clam','dace','dahl','dale','dame','deal','deil','deli','dhal','dial','dice','diel','dime','each','elhi','emic','hade','haed','haem','hail','hale','halm','hame','head','heal','heil','held','helm','hide','hied','hila','iced','idea','idem','idle','ilea','lace','lade','laic','laid','lame','lead','lech','lice','lich','lied','lima','lime','mace','mach','made','maid','mail','male','mead','meal','mech','meld','mica','mice','mild','mile','ached','ailed','aimed','alcid','almeh','amice','amide','camel','chela','chide','chiel','child','chile','chime','clade','claim','clime','decal','demic','email','haled','halid','hemal','hemic','ideal','ileac','laced','laich','lamed','leach','limed','maced','mache','macle','maile','malic','medal','media','medic','melic','miche','milch','calmed','chield','childe','chimed','chimla','haemic','hailed','halide','heliac','hiemal','lamedh','macled','mailed','malice','medial','miched','camelid','claimed','decimal','declaim','medical'};\r\nwords{2} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{6} = {'aced','ache','acid','acme','aged','ahed','ahem','aide','amid','amie','cade','cadi','cage','caid','came','cami','cedi','chad','chai','cham','chem','chia','chid','dace','dame','dice','dime','each','egad','emic','gach','gadi','gaed','game','gied','hade','haed','haem','hame','head','hide','hied','iced','idea','idem','mace','mach','made','mage','magi','maid','mead','mech','mega','mica','mice','ached','aimed','amice','amide','cadge','caged','chide','chime','demic','gamed','gamic','hemic','image','maced','mache','magic','media','medic','miche','midge','chimed','degami','gached','haemic','imaged','miched'};\r\nwords{7} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cedi','chad','chai','cham','chem','chia','chid','dace','dame','dice','dime','each','emic','hade','haed','haem','hame','head','hide','hied','iced','idea','idem','imid','mace','mach','made','maid','mead','mech','mica','mice','midi','ached','aimed','amice','amici','amide','chide','chime','demic','hemic','imide','maced','mache','media','medic','medii','miche','amidic','chimed','haemic','miched'};\r\nwords{8} = {'aced','aces','ache','acid','acme','ahed','ahem','ahis','aide','aids','aims','amid','amie','amis','asci','cade','cadi','cads','caid','came','cami','cams','case','cash','cedi','chad','chai','cham','chem','chia','chid','chis','dace','dahs','dais','dame','dams','dash','desi','dice','dies','dime','dims','disc','dish','each','edhs','emic','hade','haed','haem','haes','hame','hams','head','hems','hide','hied','hies','hims','iced','ices','ichs','idea','idem','ides','mace','mach','macs','made','mads','maes','maid','mash','mead','mech','meds','mesa','mesh','mica','mice','mics','mids','mise','sade','sadi','said','same','scad','scam','seam','semi','shad','sham','shea','shed','shim','sice','side','sidh','sima','ached','aches','acids','acmes','aides','aimed','amice','amide','amids','amies','asdic','ashed','aside','cades','cadis','caids','cames','camis','cased','cedis','chads','chais','chams','chase','chasm','chems','chias','chide','chime','daces','dames','dashi','deash','deism','demic','deshi','dices','dimes','disme','emics','hades','haems','hames','heads','hemic','hides','ideas','maced','maces','mache','machs','maids','meads','mechs','media','medic','mesic','micas','miche','sadhe','saice','shade','shame','shied','sidhe','amices','amides','camise','cashed','chaise','chased','chiasm','chides','chimed','chimes','emdash','haemic','maches','mashed','mashie','medias','medics','miched','miches','sachem','samech','schema','shamed','simcha','chamise','chasmed'};\r\nwords{9} = {'aced','ache','acid','acme','adit','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cate','cedi','chad','chai','cham','chat','chem','chia','chid','chit','cite','dace','dame','date','dice','diet','dime','dita','dite','each','eath','echt','edit','emic','emit','etch','etic','hade','haed','haem','haet','hame','hate','head','heat','hide','hied','iced','idea','idem','itch','item','mace','mach','made','maid','mate','math','mead','meat','mech','meta','meth','mica','mice','mite','tace','tach','tame','team','tech','thae','them','tide','tied','time','ached','acted','admit','aimed','aitch','amice','amide','cadet','cheat','chide','chime','cited','death','demic','demit','dicta','ditch','edict','ethic','hated','hemic','maced','mache','match','mated','media','medic','miche','tache','tamed','teach','theca','timed','chimed','dacite','detach','haemic','itched','miched','hematic','matched'};\r\nmax_score_corr = 19;\r\nmax_word_corr = {'zaideh'};\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(2);\r\nswitch ind\r\n\tcase 1\r\n\t\tfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\n\t\twords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\n\t\twords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\n\t\twords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\n\t\twords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'atheism','hamlets','hematal','thalami','thermal'};\r\n\tcase 2\r\n\t\tfirst_word = 'thinning'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\twords{2} = {'dhole','diner','drone','eloin','enrol','helio','heron','hider','hired','holed','honed','honer','horde','idler','indol','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','rhino','riled','ronde','dehorn','dinero','heroin','hinder','hoiden','holden','holder','holier','hondle','honied','horned','indole','ironed','neroli','roiled','rondel','hordein','inholder'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{8} = {'deign','diner','dinge','dingo','dirge','dogie','doing','drone','eloin','enrol','gelid','genro','geoid','giron','glide','goner','gored','gride','grind','groin','idler','indol','ingle','irone','liger','lined','liner','lingo','loden','lodge','login','loner','longe','nerol','ogled','ogler','oiled','oiler','olden','older','oldie','olein','oriel','redon','reign','renig','reoil','ridge','riled','ronde','dinero','dinger','dingle','doling','dongle','eloign','engild','engird','eringo','gilder','girdle','girned','glider','golden','golder','ignore','indole','ironed','legion','linger','lodger','logier','longed','longer','neroli','reding','regild','region','ridgel','ringed','roiled','rondel','eroding','glenoid','gloried','godlier','groined','ignored','lording','negroid','redoing'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'inholder'};\r\nend\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(2);\r\nswitch ind\r\n\tcase 1\r\n\t\tfirst_word = 'novels'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\n\t\twords{2} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','moo','oda','ode','oma','ova','oxo','vex','voe','vox','axed','dame','demo','deva','dome','doom','dove','exam','made','mead','mode','mood','move','moxa','odea','maxed','mooed','moved'};\r\n\t\twords{3} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vav','vex','voe','vox','axed','dame','demo','deva','dome','dove','exam','made','mead','mode','move','moxa','odea','maxed','moved'};\r\n\t\twords{4} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dee','dev','dex','doe','dom','eme','emo','eve','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vee','vex','voe','vox','axed','dame','deem','deme','demo','deva','dome','dove','eave','exam','exed','made','mead','meed','mode','move','moxa','odea','adeem','deave','eaved','edema','evade','maxed','moved','vexed','oedema'};\r\n\t\twords{5} = {'ad','ae','al','am','ax','da','de','do','ed','el','em','ex','la','lo','ma','me','mo','od','oe','om','ox','ado','ale','ave','avo','axe','dal','dam','del','dev','dex','doe','dol','dom','eld','elm','emo','lad','lam','lav','lax','lea','led','lev','lex','lox','mad','mae','max','med','mel','moa','mod','mol','oda','ode','old','ole','oma','ova','vex','voe','vox','alme','aloe','axed','axel','axle','dale','dame','deal','demo','deva','dole','dome','dove','exam','lade','lame','lave','lead','leva','levo','load','loam','lode','love','made','male','mead','meal','meld','mode','mola','mold','mole','move','moxa','odea','olde','olea','oval','vale','veal','vela','veld','vole','amole','axled','dolma','domal','laevo','lamed','laved','loved','loxed','maxed','medal','modal','model','moved','voled','voxel','loamed'};\r\n\t\twords{6} = {'ad','ae','am','as','ax','da','de','do','ed','em','es','ex','ma','me','mo','od','oe','om','os','ox','so','ado','ads','ave','avo','axe','dam','das','dev','dex','doe','dom','dos','eds','emo','ems','mad','mae','mas','max','med','moa','mod','mos','oda','ode','ods','oes','oma','oms','ose','ova','sad','sae','sax','sea','sev','sex','sod','som','sox','vas','vex','voe','vox','ados','aves','avos','axed','axes','dame','dams','demo','deva','devs','does','dome','doms','dosa','dose','dove','emos','exam','made','mads','maes','mead','meds','mesa','moas','mode','mods','move','moxa','odas','odea','odes','omas','oxes','sade','same','save','seam','soda','soma','some','vase','voes','dames','demos','devas','domes','doves','exams','maxed','maxes','meads','modes','moved','moves','moxas','oaves','saved','soave','vadose','vamose','vamosed'};\r\n\t\tmax_score_corr = 16;\r\n\t\tmax_word_corr = {'vexed'};\r\n\tcase 2\r\n\t\tfirst_word = 'thinning'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\twords{2} = {'dhole','diner','drone','eloin','enrol','helio','heron','hider','hired','holed','honed','honer','horde','idler','indol','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','rhino','riled','ronde','dehorn','dinero','heroin','hinder','hoiden','holden','holder','holier','hondle','honied','horned','indole','ironed','neroli','roiled','rondel','hordein','inholder'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{8} = {'deign','diner','dinge','dingo','dirge','dogie','doing','drone','eloin','enrol','gelid','genro','geoid','giron','glide','goner','gored','gride','grind','groin','idler','indol','ingle','irone','liger','lined','liner','lingo','loden','lodge','login','loner','longe','nerol','ogled','ogler','oiled','oiler','olden','older','oldie','olein','oriel','redon','reign','renig','reoil','ridge','riled','ronde','dinero','dinger','dingle','doling','dongle','eloign','engild','engird','eringo','gilder','girdle','girned','glider','golden','golder','ignore','indole','ironed','legion','linger','lodger','logier','longed','longer','neroli','reding','regild','region','ridgel','ringed','roiled','rondel','eroding','glenoid','gloried','godlier','groined','ignored','lording','negroid','redoing'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'inholder'};\r\nend\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(2);\r\nswitch ind\r\n\tcase 1\r\n\t\tfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\n\t\twords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\n\t\twords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\n\t\twords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\n\t\twords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'atheism','hamlets','hematal','thalami','thermal'};\r\n\tcase 2\r\n\t\tfirst_word = 'thinning'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\twords{2} = {'dhole','diner','drone','eloin','enrol','helio','heron','hider','hired','holed','honed','honer','horde','idler','indol','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','rhino','riled','ronde','dehorn','dinero','heroin','hinder','hoiden','holden','holder','holier','hondle','honied','horned','indole','ironed','neroli','roiled','rondel','hordein','inholder'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{8} = {'deign','diner','dinge','dingo','dirge','dogie','doing','drone','eloin','enrol','gelid','genro','geoid','giron','glide','goner','gored','gride','grind','groin','idler','indol','ingle','irone','liger','lined','liner','lingo','loden','lodge','login','loner','longe','nerol','ogled','ogler','oiled','oiler','olden','older','oldie','olein','oriel','redon','reign','renig','reoil','ridge','riled','ronde','dinero','dinger','dingle','doling','dongle','eloign','engild','engird','eringo','gilder','girdle','girned','glider','golden','golder','ignore','indole','ironed','legion','linger','lodger','logier','longed','longer','neroli','reding','regild','region','ridgel','ringed','roiled','rondel','eroding','glenoid','gloried','godlier','groined','ignored','lording','negroid','redoing'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'inholder'};\r\nend\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":223089,"edited_at":"2022-09-11T10:44:01.000Z","deleted_by":null,"deleted_at":null,"solvers_count":24,"test_suite_updated_at":"2022-09-11T10:44:01.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-20T01:12:13.000Z","updated_at":"2026-04-02T08:29:22.000Z","published_at":"2015-03-20T01:12:13.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem builds directly off of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eScrabble Scores - 10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. 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. Write a function to find the highest scoring word, provided any letter from the existing word that you are building off of and the letters on your tray.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRather 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).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 11 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (known letter \u0026amp; multipliers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 13 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3098-scrabble-scores-13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (first word \u0026amp; multipliers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":3052,"title":"Scrabble Scores - 7","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor 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.\r\n\r\nThe 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. \r\n\r\nAs an example, suppose you are given the following board (this is test case 1):\r\n\r\n   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere  \r\n\r\nThe accompanying order array will have a form like the following: \r\n\r\n  order(1) = {[2,2; 5,2]};\r\n  order(2) = {[5,1; 5,5]};\r\n  order(3) = {[1,5; 5,5]};\r\n  order(4) = {[3,5; 3,8]};\r\n  order(5) = {[1,4; 1,6]};\r\n\r\nsignifying 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].\r\n\r\nIf 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.\r\n\r\nFinally, 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.\r\n\r\nWrite a function to calculate and return the total score for each player for the provided Scrabble boards.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 6 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6 Board scoring\u003e. Next problem: 8 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8 Multiplayer multiplier board scoring\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor 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.\u003c/p\u003e\u003cp\u003eThe 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.\u003c/p\u003e\u003cp\u003eAs an example, suppose you are given the following board (this is test case 1):\u003c/p\u003e\u003cpre\u003e   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere  \u003c/pre\u003e\u003cp\u003eThe accompanying order array will have a form like the following:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eorder(1) = {[2,2; 5,2]};\r\norder(2) = {[5,1; 5,5]};\r\norder(3) = {[1,5; 5,5]};\r\norder(4) = {[3,5; 3,8]};\r\norder(5) = {[1,4; 1,6]};\r\n\u003c/pre\u003e\u003cp\u003esignifying 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].\u003c/p\u003e\u003cp\u003eIf 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.\u003c/p\u003e\u003cp\u003eFinally, 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.\u003c/p\u003e\u003cp\u003eWrite a function to calculate and return the total score for each player for the provided Scrabble boards.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 6 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6\"\u003eBoard scoring\u003c/a\u003e. Next problem: 8 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8\"\u003eMultiplayer multiplier board scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_7(board,n_pl,order)\r\n\r\nscore = zeros(1,n_pl);\r\n\r\nend\r\n\r\n","test_suite":"%%\r\nboard = [\r\n\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   ';\r\n];\r\nn_pl = 2;\r\norder = cell(1,5);\r\norder(1) = {[2,2; 5,2]};\r\norder(2) = {[5,1; 5,5]};\r\norder(3) = {[1,5; 5,5]};\r\norder(4) = {[3,5; 3,8]};\r\norder(5) = {[1,4; 1,6]};\r\nscore = [23 14];\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n\r\n%%\r\nboard = [\r\n\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    ';\r\n];\r\nn_pl = 2;\r\norder = cell(1,7);\r\norder(1) = {[1,1; 1,10]};\r\norder(2) = {[1,9; 6,9]};\r\norder(3) = {[1,2; 5,2]};\r\norder(4) = {[5,1; 5,6]};\r\norder(5) = {[5,5; 7,5]};\r\norder(6) = {[3,1; 3,5]};\r\norder(7) = {[7,2; 7,6]};\r\nscore = [29 30];\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' what   y ';\r\n'    h  do ';\r\n'  this  um';\r\n' l  n    a';\r\n' of keen t';\r\n' o   e   l';\r\n' problem a';\r\n'      noob';\r\n];\r\nn_pl = 3;\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,5]};\r\norder(2) = {[1,5; 5,5]};\r\norder(3) = {[3,3; 3,7]};\r\norder(4) = {[5,5; 5,8]};\r\norder(5) = {[5,6; 7,6]};\r\norder(6) = {[7,2; 7,8]};\r\norder(7) = {[4,2; 7,2]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [7,7; 8,7];\r\nm_words(:,:,3) = [7,8; 8,8];\r\norder(8) = {m_words};\r\norder(9) = {[3,10; 8,10]};\r\nclear m_words\r\nm_words(:,:,1) = [1,9; 3,9];\r\nm_words(:,:,2) = [3,9; 3,10];\r\norder(10) = {m_words};\r\norder(11) = {[5,2; 5,3]};\r\norder(12) = {[2,8; 2,9]};\r\nscore = [34 32 33];\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n' e    it l';\r\n' e    v  i';\r\n' please  k';\r\n'      node';\r\n];\r\nn_pl = 2;\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,3]};\r\norder(2) = {[1,3; 4,3]};\r\norder(3) = {[3,3; 3,6]};\r\norder(4) = {[1,6; 3,6]};\r\norder(5) = {[1,6; 1,8]};\r\nm_words(:,:,1) = [4,2; 4,4];\r\nm_words(:,:,2) = [3,4; 4,4];\r\norder(6) = {m_words};\r\norder(7) = {[4,2; 7,2]};\r\norder(8) = {[7,2; 7,7]};\r\norder(9) = {[4,7; 7,7]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [4,7; 8,7];\r\norder(10) = {m_words};\r\norder(11) = {[5,10; 8,10]};\r\norder(12) = {[5,7; 5,8]};\r\nscore = [43 44];\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n\r\n%%\r\nboard = [\r\n\r\n'c    flummoxes zither';\r\n'al    o      e e    e';\r\n'ba  hunting  eerie  b';\r\n'ab  a g   e    o    e';\r\n'lo  n     m g       l';\r\n' r  g      responses ';\r\n'random      n    u u ';\r\n' t  v   c  below p r ';\r\n'convention  r    e f ';\r\n' r  r   n   a   areas';\r\n' y      v c t    i c ';\r\n'   o  philosophy o em';\r\n'travel  n n r    r  e';\r\n'   e    c t         e';\r\n' word   i a    writer';\r\n'   t    n c    o    l';\r\n'p fortnight   rock  y';\r\n'i  n            h    ';\r\n'novelty m concatenate';\r\n'c e  o  a    a  s   g';\r\n'heterogeneousness   g';\r\n];\r\nn_pl = 4;\r\norder = cell(1,41);\r\norder(1) = {[12,7; 12,16]};\r\norder(2) = {[5,13; 13,13]};\r\norder(3) = {[8,9; 17,9]};\r\norder(4) = {[11,11; 17,11]};\r\norder(5) = {[17,3; 17,11]};\r\norder(6) = {[8,12; 8,16]};\r\norder(7) = {[6,12; 6,20]};\r\norder(8) = {[6,18; 13,18]};\r\norder(9) = {[10,17; 10,21]};\r\norder(10) = {[9,1; 9,10]};\r\norder(11) = {[12,4; 19,4]};\r\norder(12) = {[2,2; 11,2]};\r\norder(13) = {[7,1; 7,6]};\r\norder(14) = {[13,1; 13,6]};\r\norder(15) = {[15,2; 15,5]};\r\norder(16) = {[19,1; 19,7]};\r\norder(17) = {[3,5; 10,5]};\r\norder(18) = {[3,5; 3,11]};\r\nm_words(:,:,1) = [1,1; 5,1];\r\nm_words(:,:,2) = [2,1; 2,2];\r\nm_words(:,:,3) = [3,1; 3,2];\r\nm_words(:,:,4) = [4,1; 4,2];\r\nm_words(:,:,5) = [5,1; 5,2];\r\norder(19) = {m_words};\r\norder(20) = {[17,1; 21,1]};\r\norder(21) = {[21,1; 21,17]};\r\norder(22) = {[6,20; 12,20]};\r\nclear m_words\r\nm_words(:,:,1) = [12,21; 17,21];\r\nm_words(:,:,2) = [12,20; 12,21];\r\norder(23) = {m_words};\r\norder(24) = {[15,16; 15,21]};\r\norder(25) = {[3,11; 5,11]};\r\norder(26) = {[17,17; 21,17]};\r\norder(27) = {[17,15; 17,18]};\r\norder(28) = {[19,11; 19,21]};\r\norder(29) = {[19,14; 21,14]};\r\norder(30) = {[1,7; 4,7]};\r\norder(31) = {[1,6; 1,14]};\r\norder(32) = {[19,21; 21,21]};\r\norder(33) = {[19,6; 21,6]};\r\norder(34) = {[1,14; 3,14]};\r\norder(35) = {[3,14; 3,18]};\r\norder(36) = {[1,16; 4,16]};\r\norder(37) = {[1,16; 1,21]};\r\norder(38) = {[1,21; 5,21]};\r\norder(39) = {[19,3; 21,3]};\r\norder(40) = {[19,9; 21,9]};\r\norder(41) = {[15,16; 17,16]};\r\n\r\nscore = [127 92 128 108];\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n\r\n%% anti-cheating test case (random number of players from random board)\r\nind = randi(4);\r\nind2 = randi(3)+1;\r\nswitch ind\r\ncase 1\r\nboard = [\r\n\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   ';\r\n];\r\norder = cell(1,5);\r\norder(1) = {[2,2; 5,2]};\r\norder(2) = {[5,1; 5,5]};\r\norder(3) = {[1,5; 5,5]};\r\norder(4) = {[3,5; 3,8]};\r\norder(5) = {[1,4; 1,6]};\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [23 14];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [15 13 9];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [14 8 9 6];\r\nend\r\ncase 2\r\nboard = [\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    '];\r\norder = cell(1,7);\r\norder(1) = {[1,1; 1,10]};\r\norder(2) = {[1,9; 6,9]};\r\norder(3) = {[1,2; 5,2]};\r\norder(4) = {[5,1; 5,6]};\r\norder(5) = {[5,5; 7,5]};\r\norder(6) = {[3,1; 3,5]};\r\norder(7) = {[7,2; 7,6]};\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [29 30];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [30 13 16];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [16 18 13 12];\r\nend\r\ncase 3\r\nboard = [\r\n\r\n' what   y ';\r\n'    h  do ';\r\n'  this  um';\r\n' l  n    a';\r\n' of keen t';\r\n' o   e   l';\r\n' problem a';\r\n'      noob';\r\n];\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,5]};\r\norder(2) = {[1,5; 5,5]};\r\norder(3) = {[3,3; 3,7]};\r\norder(4) = {[5,5; 5,8]};\r\norder(5) = {[5,6; 7,6]};\r\norder(6) = {[7,2; 7,8]};\r\norder(7) = {[4,2; 7,2]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [7,7; 8,7];\r\nm_words(:,:,3) = [7,8; 8,8];\r\norder(8) = {m_words};\r\norder(9) = {[3,10; 8,10]};\r\nclear m_words\r\nm_words(:,:,1) = [1,9; 3,9];\r\nm_words(:,:,2) = [3,9; 3,10];\r\norder(10) = {m_words};\r\norder(11) = {[5,2; 5,3]};\r\norder(12) = {[2,8; 2,9]};\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [41 58];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [34 32 33];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [23 35 18 23];\r\nend\r\ncase 4\r\nboard = [\r\n\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n' e    it l';\r\n' e    v  i';\r\n' please  k';\r\n'      node';\r\n];\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,3]};\r\norder(2) = {[1,3; 4,3]};\r\norder(3) = {[3,3; 3,6]};\r\norder(4) = {[1,6; 3,6]};\r\norder(5) = {[1,6; 1,8]};\r\nm_words(:,:,1) = [4,2; 4,4];\r\nm_words(:,:,2) = [3,4; 4,4];\r\norder(6) = {m_words};\r\norder(7) = {[4,2; 7,2]};\r\norder(8) = {[7,2; 7,7]};\r\norder(9) = {[4,7; 7,7]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [4,7; 8,7];\r\norder(10) = {m_words};\r\norder(11) = {[5,10; 8,10]};\r\norder(12) = {[5,7; 5,8]};\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [43 44];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [33 29 25];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [19 28 24 16];\r\nend\r\nend\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":5,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":"2015-03-01T04:17:41.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-02-28T06:51:37.000Z","updated_at":"2026-04-02T20:16:13.000Z","published_at":"2015-03-01T04:17:41.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, suppose you are given the following board (this is test case 1):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   cat  \\n i  p   \\n t  poet\\n c  l   \\nthere]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe accompanying order array will have a form like the following:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[order(1) = {[2,2; 5,2]};\\norder(2) = {[5,1; 5,5]};\\norder(3) = {[1,5; 5,5]};\\norder(4) = {[3,5; 3,8]};\\norder(5) = {[1,4; 1,6]};]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003esignifying 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].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFinally, 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to calculate and return the total score for each player for the provided Scrabble boards.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 6 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eBoard scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 8 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer multiplier board scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3084,"title":"Scrabble Scores - 11","description":"This problem builds on the previous problem, wherein you were provided a letter of an existing word on the board and from which you played a word to find the highest scoring word. See the previous problem for more details.\r\n\r\nNow, you will be provided a multiplier character array that represents the fifteen possible squares that can be played on, ranging from seven above the existing letter (in which case the existing letter is the last letter in an eight-letter word) to seven below the 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 position. The multipliers are the same as in previous problems:\r\n\r\n * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\r\n\r\nThe center multiplier square will be left blank, since it's already covered by a tile. Write a routine to determine the highest scoring word(s) based on the multiplier squares.\r\n\r\nOnce again, you will be provided a cell array of strings containing all possible words based on the existing letter and the letters on your tray. 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).\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 10 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10 Word score optimization (known letter)\u003e. Next problem: 12 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12 Word score optimization (first word)\u003e.","description_html":"\u003cp\u003eThis problem builds on the previous problem, wherein you were provided a letter of an existing word on the board and from which you played a word to find the highest scoring word. See the previous problem for more details.\u003c/p\u003e\u003cp\u003eNow, you will be provided a multiplier character array that represents the fifteen possible squares that can be played on, ranging from seven above the existing letter (in which case the existing letter is the last letter in an eight-letter word) to seven below the 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 position. The multipliers are the same as in previous problems:\u003c/p\u003e\u003cpre\u003e * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\u003c/pre\u003e\u003cp\u003eThe center multiplier square will be left blank, since it's already covered by a tile. Write a routine to determine the highest scoring word(s) based on the multiplier squares.\u003c/p\u003e\u003cp\u003eOnce again, you will be provided a cell array of strings containing all possible words based on the existing letter and the letters on your tray. 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).\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 10 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\"\u003eWord score optimization (known letter)\u003c/a\u003e. Next problem: 12 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\"\u003eWord score optimization (first word)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score,max_word] = scrabble_scores_11(words,mult,existing_letter)\r\n\r\nscore = 0;\r\nmax_word = {''};\r\n\r\nend","test_suite":"%%\r\nexisting_letter = 's'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nmult = ' T   d   d   T '; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\nmax_score_corr = 39;\r\nmax_word_corr = {'hamlets'};\r\n[max_score,max_word] = scrabble_scores_11(words,mult,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n\r\n%%\r\nind = randi(4);\r\nexisting_letter = 's'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = ' T   d   d   T '; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 39;\r\n\t\tmax_word_corr = {'hamlets'};\r\n\tcase 2\r\n\t\tmult = 'T  D  d d  D  T'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 32;\r\n\t\tmax_word_corr = {'atheism'};\r\n\tcase 3\r\n\t\tmult = 'Q  t  T T  t  Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 153;\r\n\t\tmax_word_corr = {'halest'};\r\n\tcase 4\r\n\t\tmult = 'Q t T d d T t Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 60;\r\n\t\tmax_word_corr = {'heliast'};\r\nend\r\n[max_score,max_word] = scrabble_scores_11(words,mult,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n\r\n%%\r\nind = randi(4);\r\nexisting_letter = 't'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = ' T   d   d   T '; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 27;\r\n\t\tmax_word_corr = {'tendril','trindle'};\r\n\tcase 2\r\n\t\tmult = 'T  D  d d  D  T'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 18;\r\n\t\tmax_word_corr = {'retinol','tendril','trindle'};\r\n\tcase 3\r\n\t\tmult = 'Q  t  T T  t  Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 81;\r\n\t\tmax_word_corr = {'retinol'};\r\n\tcase 4\r\n\t\tmult = 'Q t T d d T t Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 90;\r\n\t\tmax_word_corr = {'lentoid'};\r\nend\r\n[max_score,max_word] = scrabble_scores_11(words,mult,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n\r\n%% anti-cheating test case 3\r\nind = randi(4);\r\nexisting_letter = 'n'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = ' T   d   d   T '; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 20;\r\n\t\tmax_word_corr = {'axone'};\r\n\tcase 2\r\n\t\tmult = 'T  D  d d  D  T'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 30;\r\n\t\tmax_word_corr = {'axmen'};\r\n\tcase 3\r\n\t\tmult = 'Q  t  T T  t  Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 108;\r\n\t\tmax_word_corr = {'axone'};\r\n\tcase 4\r\n\t\tmult = 'Q t T d d T t Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 45;\r\n\t\tmax_word_corr = {'axmen'};\r\nend\r\n[max_score,max_word] = scrabble_scores_11(words,mult,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n\r\n%% anti-cheating test case 4\r\nind = randi(4);\r\nexisting_letter = 'z'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'aehcmdi'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = ' T   d   d   T '; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 24;\r\n\t\tmax_word_corr = {'hazed'};\r\n\tcase 2\r\n\t\tmult = 'T  D  d d  D  T'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 40;\r\n\t\tmax_word_corr = {'zaideh'};\r\n\tcase 3\r\n\t\tmult = 'Q  t  T T  t  Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 162;\r\n\t\tmax_word_corr = {'cazh','hazed'};\r\n\tcase 4\r\n\t\tmult = 'Q t T d d T t Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 84;\r\n\t\tmax_word_corr = {'zaideh'};\r\nend\r\n[max_score,max_word] = scrabble_scores_11(words,mult,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":7,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":24,"test_suite_updated_at":"2015-03-17T13:10:14.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-15T00:22:34.000Z","updated_at":"2026-04-02T20:21:03.000Z","published_at":"2015-03-17T01:47:42.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem builds on the previous problem, wherein you were provided a letter of an existing word on the board and from which you played a word to find the highest scoring word. See the previous problem for more details.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNow, you will be provided a multiplier character array that represents the fifteen possible squares that can be played on, ranging from seven above the existing letter (in which case the existing letter is the last letter in an eight-letter word) to seven below the 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 position. The multipliers are the same as in previous problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ * D: double word\\n * T: triple word\\n * Q: quadruple word\\n * d: double letter\\n * t: triple letter\\n * q: quadruple letter]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe center multiplier square will be left blank, since it's already covered by a tile. Write a routine to determine the highest scoring word(s) based on the multiplier squares.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOnce again, you will be provided a cell array of strings containing all possible words based on the existing letter and the letters on your tray. 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).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 10 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (known letter)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 12 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (first word)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3098,"title":"Scrabble Scores - 13","description":"This problem integrates components of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11 Scrabble Scores - 11\u003e and \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12 Scrabble Scores - 12\u003e. 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).\r\n\r\nRather 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).\r\n\r\nYou 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:\r\n\r\n * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\r\n\r\nThe center multiplier square will be left blank, since it's already covered by a tile.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 12 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12 Word score optimization (first word)\u003e.","description_html":"\u003cp\u003eThis problem integrates components of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\"\u003eScrabble Scores - 11\u003c/a\u003e and \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\"\u003eScrabble Scores - 12\u003c/a\u003e. 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).\u003c/p\u003e\u003cp\u003eRather 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).\u003c/p\u003e\u003cp\u003eYou 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:\u003c/p\u003e\u003cpre\u003e * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\u003c/pre\u003e\u003cp\u003eThe center multiplier square will be left blank, since it's already covered by a tile.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 12 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\"\u003eWord score optimization (first word)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score,max_word] = scrabble_scores_13(words,mult,first_word)\r\n\r\nscore = 0;\r\nmax_word = {''};\r\n\r\nend","test_suite":"%%\r\nfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\nmult = [' T   d   d   T ';'  d   t t   d  ';' D   t   t   D ';'  d   t t   d  ';' T   d   d   T '];\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nwords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nwords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\nwords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\nwords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nmax_score_corr = 39;\r\nmax_word_corr = {'hamlets'};\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))\r\n\r\n%%\r\nfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\nmult = ['T   d     d   T';'   d       d   ';'  D   d d   D  ';'   d       d   ';'T   d     d   T'];\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nwords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nwords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\nwords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\nwords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nmax_score_corr = 30;\r\nmax_word_corr = {'maltha'};\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))\r\n\r\n%%\r\nfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\nmult = [' T  d t t d  T ';'D  t d   d t  D';' T d t   t d T ';'D  t d   d t  D';' T  d t t d  T '];\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nwords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nwords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\nwords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\nwords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nmax_score_corr = 45;\r\nmax_word_corr = {'hamlets'};\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))\r\n\r\n%%\r\nfirst_word = 'thinning'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\nwords{2} = {'dhole','diner','drone','eloin','enrol','helio','heron','hider','hired','holed','honed','honer','horde','idler','indol','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','rhino','riled','ronde','dehorn','dinero','heroin','hinder','hoiden','holden','holder','holier','hondle','honied','horned','indole','ironed','neroli','roiled','rondel','hordein','inholder'};\r\nwords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\nwords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{5} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{6} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\nwords{7} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{8} = {'deign','diner','dinge','dingo','dirge','dogie','doing','drone','eloin','enrol','gelid','genro','geoid','giron','glide','goner','gored','gride','grind','groin','idler','indol','ingle','irone','liger','lined','liner','lingo','loden','lodge','login','loner','longe','nerol','ogled','ogler','oiled','oiler','olden','older','oldie','olein','oriel','redon','reign','renig','reoil','ridge','riled','ronde','dinero','dinger','dingle','doling','dongle','eloign','engild','engird','eringo','gilder','girdle','girned','glider','golden','golder','ignore','indole','ironed','legion','linger','lodger','logier','longed','longer','neroli','reding','regild','region','ridgel','ringed','roiled','rondel','eroding','glenoid','gloried','godlier','groined','ignored','lording','negroid','redoing'};\r\nind = randi(3);\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = [' T   d   d   T ';'  d   t t   d  ';' D   t   t   D ';'   D       D   ';'   D       D   ';' D   t   t   D ';'  d   t t   d  ';' T   d   d   T '];\r\n\t\tmax_score_corr = 33;\r\n\t\tmax_word_corr = {'godlier'};\r\n\tcase 2\r\n\t\tmult = ['T   d     d   T';'   d       d   ';'  D   d d   D  ';'   d       d   ';'T   d     d   T';'   d       d   ';'  D   d d   D  ';'   d       d   '];\r\n\t\tmax_score_corr = 16;\r\n\t\tmax_word_corr = {'indole','iodine','ironed','endrin','linden'};\r\n\tcase 3\r\n\t\tmult = ['T   d     d   T';' T  d t t d  T ';'D  t d   d t  D';' T d t   t d T ';'  T   d d   T  ';' T d t   t d T ';'D  t d   d t  D';' T  d t t d  T '];\r\n\t\tmax_score_corr = 45;\r\n\t\tmax_word_corr = {'hordein'};\r\nend\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))\r\n\r\n%%\r\nfirst_word = 'novels'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\nwords{2} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','moo','oda','ode','oma','ova','oxo','vex','voe','vox','axed','dame','demo','deva','dome','doom','dove','exam','made','mead','mode','mood','move','moxa','odea','maxed','mooed','moved'};\r\nwords{3} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vav','vex','voe','vox','axed','dame','demo','deva','dome','dove','exam','made','mead','mode','move','moxa','odea','maxed','moved'};\r\nwords{4} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dee','dev','dex','doe','dom','eme','emo','eve','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vee','vex','voe','vox','axed','dame','deem','deme','demo','deva','dome','dove','eave','exam','exed','made','mead','meed','mode','move','moxa','odea','adeem','deave','eaved','edema','evade','maxed','moved','vexed','oedema'};\r\nwords{5} = {'ad','ae','al','am','ax','da','de','do','ed','el','em','ex','la','lo','ma','me','mo','od','oe','om','ox','ado','ale','ave','avo','axe','dal','dam','del','dev','dex','doe','dol','dom','eld','elm','emo','lad','lam','lav','lax','lea','led','lev','lex','lox','mad','mae','max','med','mel','moa','mod','mol','oda','ode','old','ole','oma','ova','vex','voe','vox','alme','aloe','axed','axel','axle','dale','dame','deal','demo','deva','dole','dome','dove','exam','lade','lame','lave','lead','leva','levo','load','loam','lode','love','made','male','mead','meal','meld','mode','mola','mold','mole','move','moxa','odea','olde','olea','oval','vale','veal','vela','veld','vole','amole','axled','dolma','domal','laevo','lamed','laved','loved','loxed','maxed','medal','modal','model','moved','voled','voxel','loamed'};\r\nwords{6} = {'ad','ae','am','as','ax','da','de','do','ed','em','es','ex','ma','me','mo','od','oe','om','os','ox','so','ado','ads','ave','avo','axe','dam','das','dev','dex','doe','dom','dos','eds','emo','ems','mad','mae','mas','max','med','moa','mod','mos','oda','ode','ods','oes','oma','oms','ose','ova','sad','sae','sax','sea','sev','sex','sod','som','sox','vas','vex','voe','vox','ados','aves','avos','axed','axes','dame','dams','demo','deva','devs','does','dome','doms','dosa','dose','dove','emos','exam','made','mads','maes','mead','meds','mesa','moas','mode','mods','move','moxa','odas','odea','odes','omas','oxes','sade','same','save','seam','soda','soma','some','vase','voes','dames','demos','devas','domes','doves','exams','maxed','maxes','meads','modes','moved','moves','moxas','oaves','saved','soave','vadose','vamose','vamosed'};\r\nind = randi(3);\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = [' T   d   d   T ';'  d   t t   d  ';' D   t   t   D ';'   D       D   ';'   D       D   ';' D   t   t   D '];\r\n\t\tmax_score_corr = 37;\r\n\t\tmax_word_corr = {'vox'};\r\n\tcase 2\r\n\t\tmult = ['T   d     d   T';'  D   d d   D  ';'   d       d   ';'T   d     d   T';'   d       d   ';'  D   d d   D  '];\r\n\t\tmax_score_corr = 25;\r\n\t\tmax_word_corr = {'vox'};\r\n\tcase 3\r\n\t\tmult = [' T  d t t d  T ';'D  t d   d t  D';' T d t   t d T ';'  T   d d   T  ';' T d t   t d T ';'D  t d   d t  D'];\r\n\t\tmax_score_corr = 35;\r\n\t\tmax_word_corr = {'voxel'};\r\nend\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))\r\n\r\n%%\r\nfirst_word = 'zoologist'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aehcmdi'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\nwords{2} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{3} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{4} = {'aced','ache','acid','acme','ahed','ahem','aide','alec','alme','amid','amie','cade','cadi','caid','calm','came','cami','cedi','ceil','chad','chai','cham','chem','chia','chid','clad','clam','dace','dahl','dale','dame','deal','deil','deli','dhal','dial','dice','diel','dime','each','elhi','emic','hade','haed','haem','hail','hale','halm','hame','head','heal','heil','held','helm','hide','hied','hila','iced','idea','idem','idle','ilea','lace','lade','laic','laid','lame','lead','lech','lice','lich','lied','lima','lime','mace','mach','made','maid','mail','male','mead','meal','mech','meld','mica','mice','mild','mile','ached','ailed','aimed','alcid','almeh','amice','amide','camel','chela','chide','chiel','child','chile','chime','clade','claim','clime','decal','demic','email','haled','halid','hemal','hemic','ideal','ileac','laced','laich','lamed','leach','limed','maced','mache','macle','maile','malic','medal','media','medic','melic','miche','milch','calmed','chield','childe','chimed','chimla','haemic','hailed','halide','heliac','hiemal','lamedh','macled','mailed','malice','medial','miched','camelid','claimed','decimal','declaim','medical'};\r\nwords{5} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{6} = {'aced','ache','acid','acme','aged','ahed','ahem','aide','amid','amie','cade','cadi','cage','caid','came','cami','cedi','chad','chai','cham','chem','chia','chid','dace','dame','dice','dime','each','egad','emic','gach','gadi','gaed','game','gied','hade','haed','haem','hame','head','hide','hied','iced','idea','idem','mace','mach','made','mage','magi','maid','mead','mech','mega','mica','mice','ached','aimed','amice','amide','cadge','caged','chide','chime','demic','gamed','gamic','hemic','image','maced','mache','magic','media','medic','miche','midge','chimed','degami','gached','haemic','imaged','miched'};\r\nwords{7} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cedi','chad','chai','cham','chem','chia','chid','dace','dame','dice','dime','each','emic','hade','haed','haem','hame','head','hide','hied','iced','idea','idem','imid','mace','mach','made','maid','mead','mech','mica','mice','midi','ached','aimed','amice','amici','amide','chide','chime','demic','hemic','imide','maced','mache','media','medic','medii','miche','amidic','chimed','haemic','miched'};\r\nwords{8} = {'aced','aces','ache','acid','acme','ahed','ahem','ahis','aide','aids','aims','amid','amie','amis','asci','cade','cadi','cads','caid','came','cami','cams','case','cash','cedi','chad','chai','cham','chem','chia','chid','chis','dace','dahs','dais','dame','dams','dash','desi','dice','dies','dime','dims','disc','dish','each','edhs','emic','hade','haed','haem','haes','hame','hams','head','hems','hide','hied','hies','hims','iced','ices','ichs','idea','idem','ides','mace','mach','macs','made','mads','maes','maid','mash','mead','mech','meds','mesa','mesh','mica','mice','mics','mids','mise','sade','sadi','said','same','scad','scam','seam','semi','shad','sham','shea','shed','shim','sice','side','sidh','sima','ached','aches','acids','acmes','aides','aimed','amice','amide','amids','amies','asdic','ashed','aside','cades','cadis','caids','cames','camis','cased','cedis','chads','chais','chams','chase','chasm','chems','chias','chide','chime','daces','dames','dashi','deash','deism','demic','deshi','dices','dimes','disme','emics','hades','haems','hames','heads','hemic','hides','ideas','maced','maces','mache','machs','maids','meads','mechs','media','medic','mesic','micas','miche','sadhe','saice','shade','shame','shied','sidhe','amices','amides','camise','cashed','chaise','chased','chiasm','chides','chimed','chimes','emdash','haemic','maches','mashed','mashie','medias','medics','miched','miches','sachem','samech','schema','shamed','simcha','chamise','chasmed'};\r\nwords{9} = {'aced','ache','acid','acme','adit','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cate','cedi','chad','chai','cham','chat','chem','chia','chid','chit','cite','dace','dame','date','dice','diet','dime','dita','dite','each','eath','echt','edit','emic','emit','etch','etic','hade','haed','haem','haet','hame','hate','head','heat','hide','hied','iced','idea','idem','itch','item','mace','mach','made','maid','mate','math','mead','meat','mech','meta','meth','mica','mice','mite','tace','tach','tame','team','tech','thae','them','tide','tied','time','ached','acted','admit','aimed','aitch','amice','amide','cadet','cheat','chide','chime','cited','death','demic','demit','dicta','ditch','edict','ethic','hated','hemic','maced','mache','match','mated','media','medic','miche','tache','tamed','teach','theca','timed','chimed','dacite','detach','haemic','itched','miched','hematic','matched'};\r\nind = randi(3);\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = [' T   d   d   T ';'  d   t t   d  ';' D   t   t   D ';'   D       D   ';' d   T   T   d ';'   D       D   ';' D   t   t   D ';'  d   t t   d  ';' T   d   d   T '];\r\n\t\tmax_score_corr = 117;\r\n\t\tmax_word_corr = {'haemoid'};\r\n\tcase 2\r\n\t\tmult = ['T   d     d   T';'   d       d   ';'  D   d d   D  ';'   d       d   ';'T   d     d   T';'   d       d   ';'  D   d d   D  ';'   d       d   ';'T   d     d   T'];\r\n\t\tmax_score_corr = 28;\r\n\t\tmax_word_corr = {'medico'};\r\n\tcase 3\r\n\t\tmult = ['T   d     d   T';' T  d t t d  T ';'D  t d   d t  D';' T d t   t d T ';'  T   d d   T  ';' T d t   t d T ';'D  t d   d t  D';' T  d t t d  T ';'T   d     d   T'];\r\n\t\tmax_score_corr = 63;\r\n\t\tmax_word_corr = {'decimal'};\r\nend\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))","published":true,"deleted":false,"likes_count":2,"comments_count":6,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":18,"test_suite_updated_at":"2015-03-20T18:02:10.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-20T01:53:26.000Z","updated_at":"2026-04-02T20:22:25.000Z","published_at":"2015-03-20T01:53:26.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem integrates components of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eScrabble Scores - 11\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eScrabble Scores - 12\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. 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).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRather 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).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou 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:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ * D: double word\\n * T: triple word\\n * Q: quadruple word\\n * d: double letter\\n * t: triple letter\\n * q: quadruple letter]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe center multiplier square will be left blank, since it's already covered by a tile.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 12 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (first word)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3060,"title":"Scrabble Scores - 8","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you are tasked with scoring a completed multiplayer Scrabble board. You will be provided with a character matrix representing a completed game of Scrabble, the number of players (two to four), an order array denoting the order of word placement, and a multiplier board that corresponds to the character board.\r\n\r\nSee the previous problem for details on the order array (link below). All other details from that problem should be carried over. The multiplier board will be a character matrix of the same size as the board with the following single-letter entries for letter (lowercase) or word (uppercase) multipliers:\r\n\r\n * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\r\n\r\nAs an example, suppose you are given the following board (this is test case 1):\r\n\r\n   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere  \r\n\r\nThe multiplier matrix looks like this:\r\n\r\n  T   d  T\r\n          \r\n  d   D  d\r\n          \r\n  T   d  T\r\n\r\nThe first word to be played, itch, does not cover any multiplier squares, so it is scored as usual. The second word, there, covers the triple-word (T) square in the bottom-left corner in addition to the double-letter (d) square in the bottom center. This means that the last e is doubled (2 points instead of 1) and the entire word score is then tripled.\r\n\r\nThe next word to be played, apple, covers the middle double-word (D) square and the top double-letter (d) square. However, the bottom double-letter (d) square was covered by the previous word and is, therefore, not counted again, per Scrabble rules. So, you'll need to make sure that the entries in the multiplier matrix are cleared out as they are covered with tiles. Each multiplier square counts for all the words scored in a turn (if more than one), but then is covered up for subsequent words.\r\n\r\nWrite a function to calculate and return the total score for each player for the provided Scrabble boards using the accompanying multiplier matrices.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 7 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7 Multiplayer board scoring\u003e. Next problem: 9 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9 Optimal word score\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you are tasked with scoring a completed multiplayer Scrabble board. You will be provided with a character matrix representing a completed game of Scrabble, the number of players (two to four), an order array denoting the order of word placement, and a multiplier board that corresponds to the character board.\u003c/p\u003e\u003cp\u003eSee the previous problem for details on the order array (link below). All other details from that problem should be carried over. The multiplier board will be a character matrix of the same size as the board with the following single-letter entries for letter (lowercase) or word (uppercase) multipliers:\u003c/p\u003e\u003cpre\u003e * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\u003c/pre\u003e\u003cp\u003eAs an example, suppose you are given the following board (this is test case 1):\u003c/p\u003e\u003cpre\u003e   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere  \u003c/pre\u003e\u003cp\u003eThe multiplier matrix looks like this:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eT   d  T\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003ed   D  d\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eT   d  T\r\n\u003c/pre\u003e\u003cp\u003eThe first word to be played, itch, does not cover any multiplier squares, so it is scored as usual. The second word, there, covers the triple-word (T) square in the bottom-left corner in addition to the double-letter (d) square in the bottom center. This means that the last e is doubled (2 points instead of 1) and the entire word score is then tripled.\u003c/p\u003e\u003cp\u003eThe next word to be played, apple, covers the middle double-word (D) square and the top double-letter (d) square. However, the bottom double-letter (d) square was covered by the previous word and is, therefore, not counted again, per Scrabble rules. So, you'll need to make sure that the entries in the multiplier matrix are cleared out as they are covered with tiles. Each multiplier square counts for all the words scored in a turn (if more than one), but then is covered up for subsequent words.\u003c/p\u003e\u003cp\u003eWrite a function to calculate and return the total score for each player for the provided Scrabble boards using the accompanying multiplier matrices.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 7 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7\"\u003eMultiplayer board scoring\u003c/a\u003e. Next problem: 9 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9\"\u003eOptimal word score\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_8(board,n_pl,order,mult)\r\n\r\nscore = zeros(1,n_pl);\r\n\r\nend\r\n","test_suite":"%%\r\nboard = [\r\n\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   ';\r\n];\r\nn_pl = 2;\r\norder = cell(1,5);\r\norder(1) = {[2,2; 5,2]};\r\norder(2) = {[5,1; 5,5]};\r\norder(3) = {[1,5; 5,5]};\r\norder(4) = {[3,5; 3,8]};\r\norder(5) = {[1,4; 1,6]};\r\nmult = [\r\n\r\n'T   d  T';\r\n'        ';\r\n'd   D  d';\r\n'        ';\r\n'T   d  T';\r\n];\r\nscore = [34 34];\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n\r\n%%\r\nboard = [\r\n\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    ';\r\n];\r\nn_pl = 2;\r\norder = cell(1,7);\r\norder(1) = {[1,1; 1,10]};\r\norder(2) = {[1,9; 6,9]};\r\norder(3) = {[1,2; 5,2]};\r\norder(4) = {[5,1; 5,6]};\r\norder(5) = {[5,5; 7,5]};\r\norder(6) = {[3,1; 3,5]};\r\norder(7) = {[7,2; 7,6]};\r\nmult = [\r\n\r\n'T  t  t  T';\r\n'          ';\r\n'D  d  d  D';\r\n'          ';\r\n'D  d  d  D';\r\n'          ';\r\n'T  t  t  T';\r\n];\r\nscore = [189 54];\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' what   y ';\r\n'    h  do ';\r\n'  this  um';\r\n' l  n    a';\r\n' of keen t';\r\n' o   e   l';\r\n' problem a';\r\n'      noob';\r\n];\r\nn_pl = 3;\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,5]};\r\norder(2) = {[1,5; 5,5]};\r\norder(3) = {[3,3; 3,7]};\r\norder(4) = {[5,5; 5,8]};\r\norder(5) = {[5,6; 7,6]};\r\norder(6) = {[7,2; 7,8]};\r\norder(7) = {[4,2; 7,2]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [7,7; 8,7];\r\nm_words(:,:,3) = [7,8; 8,8];\r\norder(8) = {m_words};\r\norder(9) = {[3,10; 8,10]};\r\nclear m_words\r\nm_words(:,:,1) = [1,9; 3,9];\r\nm_words(:,:,2) = [3,9; 3,10];\r\norder(10) = {m_words};\r\norder(11) = {[5,2; 5,3]};\r\norder(12) = {[2,8; 2,9]};\r\nmult = [\r\n\r\n'T    t   T';\r\n' d      d ';\r\n'  d    d  ';\r\n'   D     t';\r\n't     D   ';\r\n'  d    d  ';\r\n' d      d ';\r\n'T   t    T';\r\n];\r\nscore = [43 44 39];\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n' e    it l';\r\n' e    v  i';\r\n' please  k';\r\n'      node';\r\n];\r\nn_pl = 2;\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,3]};\r\norder(2) = {[1,3; 4,3]};\r\norder(3) = {[3,3; 3,6]};\r\norder(4) = {[1,6; 3,6]};\r\norder(5) = {[1,6; 1,8]};\r\nm_words(:,:,1) = [4,2; 4,4];\r\nm_words(:,:,2) = [3,4; 4,4];\r\norder(6) = {m_words};\r\norder(7) = {[4,2; 7,2]};\r\norder(8) = {[7,2; 7,7]};\r\norder(9) = {[4,7; 7,7]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [4,7; 8,7];\r\norder(10) = {m_words};\r\norder(11) = {[5,10; 8,10]};\r\norder(12) = {[5,7; 5,8]};\r\nmult = [\r\n\r\n' T   T  T ';\r\n'   d     d';\r\n'  D   D   ';\r\n' D t  d   ';\r\n'         d';\r\n'   d  t   ';\r\n' d  D   D ';\r\n'  T   T  T';\r\n];\r\nscore = [67 140];\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n\r\n%\r\nboard = [\r\n\r\n'c    flummoxes zither';\r\n'al    o      e e    e';\r\n'ba  hunting  eerie  b';\r\n'ab  a g   e    o    e';\r\n'lo  n     m g       l';\r\n' r  g      responses ';\r\n'random      n    u u ';\r\n' t  v   c  below p r ';\r\n'convention  r    e f ';\r\n' r  r   n   a   areas';\r\n' y      v c t    i c ';\r\n'   o  philosophy o em';\r\n'travel  n n r    r  e';\r\n'   e    c t         e';\r\n' word   i a    writer';\r\n'   t    n c    o    l';\r\n'p fortnight   rock  y';\r\n'i  n            h    ';\r\n'novelty m concatenate';\r\n'c e  o  a    a  s   g';\r\n'heterogeneousness   g';\r\n];\r\nn_pl = 4;\r\norder = cell(1,41);\r\norder(1) = {[12,7; 12,16]};\r\norder(2) = {[5,13; 13,13]};\r\norder(3) = {[8,9; 17,9]};\r\norder(4) = {[11,11; 17,11]};\r\norder(5) = {[17,3; 17,11]};\r\norder(6) = {[8,12; 8,16]};\r\norder(7) = {[6,12; 6,20]};\r\norder(8) = {[6,18; 13,18]};\r\norder(9) = {[10,17; 10,21]};\r\norder(10) = {[9,1; 9,10]};\r\norder(11) = {[12,4; 19,4]};\r\norder(12) = {[2,2; 11,2]};\r\norder(13) = {[7,1; 7,6]};\r\norder(14) = {[13,1; 13,6]};\r\norder(15) = {[15,2; 15,5]};\r\norder(16) = {[19,1; 19,7]};\r\norder(17) = {[3,5; 10,5]};\r\norder(18) = {[3,5; 3,11]};\r\nm_words(:,:,1) = [1,1; 5,1];\r\nm_words(:,:,2) = [2,1; 2,2];\r\nm_words(:,:,3) = [3,1; 3,2];\r\nm_words(:,:,4) = [4,1; 4,2];\r\nm_words(:,:,5) = [5,1; 5,2];\r\norder(19) = {m_words};\r\norder(20) = {[17,1; 21,1]};\r\norder(21) = {[21,1; 21,17]};\r\norder(22) = {[6,20; 12,20]};\r\nclear m_words\r\nm_words(:,:,1) = [12,21; 17,21];\r\nm_words(:,:,2) = [12,20; 12,21];\r\norder(23) = {m_words};\r\norder(24) = {[15,16; 15,21]};\r\norder(25) = {[3,11; 5,11]};\r\norder(26) = {[17,17; 21,17]};\r\norder(27) = {[17,15; 17,18]};\r\norder(28) = {[19,11; 19,21]};\r\norder(29) = {[19,14; 21,14]};\r\norder(30) = {[1,7; 4,7]};\r\norder(31) = {[1,6; 1,14]};\r\norder(32) = {[19,21; 21,21]};\r\norder(33) = {[19,6; 21,6]};\r\norder(34) = {[1,14; 3,14]};\r\norder(35) = {[3,14; 3,18]};\r\norder(36) = {[1,16; 4,16]};\r\norder(37) = {[1,16; 1,21]};\r\norder(38) = {[1,21; 5,21]};\r\norder(39) = {[19,3; 21,3]};\r\norder(40) = {[19,9; 21,9]};\r\norder(41) = {[15,16; 17,16]};\r\nmult = [\r\n\r\n'Q  d   T  d  T   d  Q';\r\n' D  t   D   D   t  D ';\r\n'  D  q   D D   q  D  ';\r\n'd  T  d   T   d  T  d';\r\n' t  D   t   t   D  t ';\r\n'  q  D   d d   D  q  ';\r\n'   d  D   d   D  d   ';\r\n'T      D     D      T';\r\n' D  t   t   t   t  D ';\r\n'  D  d   d d   d  D  ';\r\n'd   T d   D   d  T  d';\r\n'  D  d   d d   d  D  ';\r\n' D  t   t   t   t  D ';\r\n'T      D     D      T';\r\n'   d  D   d   D  d   ';\r\n'  q  D   d d   D  q  ';\r\n' t  D   t   t   D  t ';\r\n'd  T  d   T   d  T  d';\r\n'  D  q   D D   q  D  ';\r\n' D  t   D   D   t  D ';\r\n'Q  d   T  d  T   d  Q';\r\n];\r\nscore = [433 188 430 300];\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n\r\n%% anti-cheating test case (random number of players from random board)\r\nind = randi(4);\r\nind2 = randi(3)+1;\r\nswitch ind\r\ncase 1\r\nboard = [\r\n\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   ';\r\n];\r\norder = cell(1,5);\r\norder(1) = {[2,2; 5,2]};\r\norder(2) = {[5,1; 5,5]};\r\norder(3) = {[1,5; 5,5]};\r\norder(4) = {[3,5; 3,8]};\r\norder(5) = {[1,4; 1,6]};\r\nmult = [\r\n\r\n'T   d  T';\r\n'        ';\r\n'd   D  d';\r\n'        ';\r\n'T   d  T';\r\n];\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [34 34];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [16 32 20];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [14 27 20 7];\r\nend\r\ncase 2\r\nboard = [\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    '];\r\norder = cell(1,7);\r\norder(1) = {[1,1; 1,10]};\r\norder(2) = {[1,9; 6,9]};\r\norder(3) = {[1,2; 5,2]};\r\norder(4) = {[5,1; 5,6]};\r\norder(5) = {[5,5; 7,5]};\r\norder(6) = {[3,1; 3,5]};\r\norder(7) = {[7,2; 7,6]};\r\nmult = [\r\n\r\n'T  t  t  T';\r\n'          ';\r\n'D  d  d  D';\r\n'          ';\r\n'D  d  d  D';\r\n'          ';\r\n'T  t  t  T';\r\n];\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [189 54];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [204 13 26];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [174 28 15 26];\r\nend\r\ncase 3\r\nboard = [\r\n\r\n' what   y ';\r\n'    h  do ';\r\n'  this  um';\r\n' l  n    a';\r\n' of keen t';\r\n' o   e   l';\r\n' problem a';\r\n'      noob';\r\n];\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,5]};\r\norder(2) = {[1,5; 5,5]};\r\norder(3) = {[3,3; 3,7]};\r\norder(4) = {[5,5; 5,8]};\r\norder(5) = {[5,6; 7,6]};\r\norder(6) = {[7,2; 7,8]};\r\norder(7) = {[4,2; 7,2]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [7,7; 8,7];\r\nm_words(:,:,3) = [7,8; 8,8];\r\norder(8) = {m_words};\r\norder(9) = {[3,10; 8,10]};\r\nclear m_words\r\nm_words(:,:,1) = [1,9; 3,9];\r\nm_words(:,:,2) = [3,9; 3,10];\r\norder(10) = {m_words};\r\norder(11) = {[5,2; 5,3]};\r\norder(12) = {[2,8; 2,9]};\r\nmult = [\r\n\r\n'T    t   T';\r\n' d      d ';\r\n'  d    d  ';\r\n'   D     t';\r\n't     D   ';\r\n'  d    d  ';\r\n' d      d ';\r\n'T   t    T';\r\n];\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [44 82];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [43 44 39];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [25 39 19 43];\r\nend\r\ncase 4\r\nboard = [\r\n\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n' e    it l';\r\n' e    v  i';\r\n' please  k';\r\n'      node';\r\n];\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,3]};\r\norder(2) = {[1,3; 4,3]};\r\norder(3) = {[3,3; 3,6]};\r\norder(4) = {[1,6; 3,6]};\r\norder(5) = {[1,6; 1,8]};\r\nm_words(:,:,1) = [4,2; 4,4];\r\nm_words(:,:,2) = [3,4; 4,4];\r\norder(6) = {m_words};\r\norder(7) = {[4,2; 7,2]};\r\norder(8) = {[7,2; 7,7]};\r\norder(9) = {[4,7; 7,7]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [4,7; 8,7];\r\norder(10) = {m_words};\r\norder(11) = {[5,10; 8,10]};\r\norder(12) = {[5,7; 5,8]};\r\nmult = [\r\n\r\n' T   T  T ';\r\n'   d     d';\r\n'  D   D   ';\r\n' D t  d   ';\r\n'         d';\r\n'   d  t   ';\r\n' d  D   D ';\r\n'  T   T  T';\r\n];\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [67 140];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [116 45 46];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [39 104 28 36];\r\nend\r\nend\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":23,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-03T05:04:53.000Z","updated_at":"2026-04-02T20:17:44.000Z","published_at":"2015-03-03T05:04:53.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you are tasked with scoring a completed multiplayer Scrabble board. You will be provided with a character matrix representing a completed game of Scrabble, the number of players (two to four), an order array denoting the order of word placement, and a multiplier board that corresponds to the character board.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee the previous problem for details on the order array (link below). All other details from that problem should be carried over. The multiplier board will be a character matrix of the same size as the board with the following single-letter entries for letter (lowercase) or word (uppercase) multipliers:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ * D: double word\\n * T: triple word\\n * Q: quadruple word\\n * d: double letter\\n * t: triple letter\\n * q: quadruple letter]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, suppose you are given the following board (this is test case 1):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   cat  \\n i  p   \\n t  poet\\n c  l   \\nthere]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe multiplier matrix looks like this:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[T   d  T\\n\\nd   D  d\\n\\nT   d  T]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe first word to be played, itch, does not cover any multiplier squares, so it is scored as usual. The second word, there, covers the triple-word (T) square in the bottom-left corner in addition to the double-letter (d) square in the bottom center. This means that the last e is doubled (2 points instead of 1) and the entire word score is then tripled.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe next word to be played, apple, covers the middle double-word (D) square and the top double-letter (d) square. However, the bottom double-letter (d) square was covered by the previous word and is, therefore, not counted again, per Scrabble rules. So, you'll need to make sure that the entries in the multiplier matrix are cleared out as they are covered with tiles. Each multiplier square counts for all the words scored in a turn (if more than one), but then is covered up for subsequent words.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to calculate and return the total score for each player for the provided Scrabble boards using the accompanying multiplier matrices.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 7 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer board scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 9 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOptimal word score\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":3047,"title":"Scrabble Scores - 2","description":"An \u003chttps://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores introductory Cody problem\u003e asks the user to score a Scrabble word. This problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine.\r\n\r\nScrabble is a word board game wherein each letter tile is scored roughly according to its frequency (or lack thereof) in words. More common letters, such as vowels, are worth fewer points while difficult letters, such as Q, Z, J, and X are worth more points. The point distribution is provided \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you will be provided with a cell array of words (e.g., all the words from one player in a game). Write a function to calculate the total score for the set of words.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 1 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores Single-word scoring\u003e. Next problem: 3 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3 Single-word multiplier scoring\u003e.\r\n","description_html":"\u003cp\u003eAn \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores\"\u003eintroductory Cody problem\u003c/a\u003e asks the user to score a Scrabble word. This problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine.\u003c/p\u003e\u003cp\u003eScrabble is a word board game wherein each letter tile is scored roughly according to its frequency (or lack thereof) in words. More common letters, such as vowels, are worth fewer points while difficult letters, such as Q, Z, J, and X are worth more points. The point distribution is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a cell array of words (e.g., all the words from one player in a game). Write a function to calculate the total score for the set of words.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 1 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores\"\u003eSingle-word scoring\u003c/a\u003e. Next problem: 3 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3\"\u003eSingle-word multiplier scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_2(words)\r\n\r\nscore = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nwords = {'hello','there','fellow','matlab','users'};\r\nscore = 43;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%%\r\nwords = {'what','do','you','think','of','this','problem'};\r\nscore = 56;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%%\r\nwords = {'if','you','like','it','please','give','it','a','like'};\r\nscore = 48;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%%\r\nwords = {'zither','quandry','flummox','wealthy','amalgam'};\r\nscore = 87;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%%\r\nwords = {'one','two','three','four','five'};\r\nscore = 34;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%%\r\nwords = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\nscore = [17 21 15 12 5];\r\nind = randi(5);\r\nassert(isequal(scrabble_scores_2(words(ind)),score(ind)))\r\n\r\n%%\r\nwords = {'perspicacious','yes','zero','quizzical','no'};\r\nscore = [21 6 13 38 2];\r\nind = randi(5);\r\nassert(isequal(scrabble_scores_2(words(ind)),score(ind)))\r\n\r\n%% pangram test (one string) to help ensure letters scores are correctly assigned\r\nwords = {'the quick brown fox jumps over a lazy dog'};\r\nscore = 94;\r\nassert(isequal(scrabble_scores_2(words),score))\r\n\r\n%% pangram test (multiple words) to help ensure letters scores are correctly assigned\r\nwords = {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\nscore = 94;\r\nassert(isequal(scrabble_scores_2(words),score))","published":true,"deleted":false,"likes_count":2,"comments_count":7,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":"2015-02-28T02:22:30.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-02-26T04:07:25.000Z","updated_at":"2026-04-02T20:07:44.000Z","published_at":"2015-02-26T04:07:24.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAn\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eintroductory Cody problem\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e asks the user to score a Scrabble word. This problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eScrabble is a word board game wherein each letter tile is scored roughly according to its frequency (or lack thereof) in words. More common letters, such as vowels, are worth fewer points while difficult letters, such as Q, Z, J, and X are worth more points. The point distribution is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a cell array of words (e.g., all the words from one player in a game). Write a function to calculate the total score for the set of words.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 1 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/56-scrabble-scores\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSingle-word scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 3 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSingle-word multiplier scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3018,"title":"Calculator spelling - Numbers to Letters","description":"Using the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\r\n\r\n* 0 = O\r\n* 1 = I\r\n* 2 = Z\r\n* 3 = E\r\n* 4 = h\r\n* 5 = S\r\n* 6 = g\r\n* 7 = L\r\n* 8 = B\r\n\r\nThere are a few other options, but we'll stick with these. The number may be a have a decimal with a leading zero, to produce a trailing O. If this is the case, ignore the decimal point. Write a function that takes a number as input and returns the word spelled (upside down) by the calculator. Make sure to get the case (capital vs. lowercase) right for each number/letter.\r\n\r\nThis problem is related to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3019-calculator-spelling-letters-to-numbers Problem 3019\u003e.","description_html":"\u003cp\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\u003c/p\u003e\u003cul\u003e\u003cli\u003e0 = O\u003c/li\u003e\u003cli\u003e1 = I\u003c/li\u003e\u003cli\u003e2 = Z\u003c/li\u003e\u003cli\u003e3 = E\u003c/li\u003e\u003cli\u003e4 = h\u003c/li\u003e\u003cli\u003e5 = S\u003c/li\u003e\u003cli\u003e6 = g\u003c/li\u003e\u003cli\u003e7 = L\u003c/li\u003e\u003cli\u003e8 = B\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThere are a few other options, but we'll stick with these. The number may be a have a decimal with a leading zero, to produce a trailing O. If this is the case, ignore the decimal point. Write a function that takes a number as input and returns the word spelled (upside down) by the calculator. Make sure to get the case (capital vs. lowercase) right for each number/letter.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3019-calculator-spelling-letters-to-numbers\"\u003eProblem 3019\u003c/a\u003e.\u003c/p\u003e","function_template":"function [word] = calc_spell_word(n)\r\n\r\nword = num2str(n);\r\n\r\nend\r\n","test_suite":"%%\r\nn = 35007;\r\ntxt = 'LOOSE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 77345;\r\ntxt = 'ShELL';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 36138;\r\ntxt = 'BEIgE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 378806;\r\ntxt = 'gOBBLE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 376006;\r\ntxt = 'gOOgLE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 57738461375;\r\ntxt = 'SLEIghBELLS';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 0.7734;\r\ntxt = 'hELLO';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 53045;\r\ntxt = 'ShOES';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 771;\r\ntxt = 'ILL';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 345;\r\ntxt = 'ShE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 7735;\r\ntxt = 'SELL';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nind = randi(4);\r\nn_arr = [36138 707 7714 57738];\r\nn = n_arr(ind);\r\ntxt_arr = {'BEIgE','LOL','hILL','BELLS'};\r\ntxt = txt_arr{ind};\r\nassert(isequal(calc_spell_word(n),txt))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":72,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-14T22:05:44.000Z","updated_at":"2026-03-19T20:03:05.000Z","published_at":"2015-02-14T22:05:44.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e0 = O\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1 = I\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2 = Z\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e3 = E\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e4 = h\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e5 = S\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e6 = g\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e7 = L\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e8 = B\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThere are a few other options, but we'll stick with these. The number may be a have a decimal with a leading zero, to produce a trailing O. If this is the case, ignore the decimal point. Write a function that takes a number as input and returns the word spelled (upside down) by the calculator. Make sure to get the case (capital vs. lowercase) right for each number/letter.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3019-calculator-spelling-letters-to-numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3019\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3019,"title":"Calculator spelling - Letters to Numbers","description":"Using the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\r\n\r\n* 0 = O\r\n* 1 = I\r\n* 2 = Z\r\n* 3 = E\r\n* 4 = h\r\n* 5 = S\r\n* 6 = g\r\n* 7 = L\r\n* 8 = B\r\n\r\nThere are a few other options, but we'll stick with these. If the word has a trailing O, the number will need a decimal point to produce a leading zero. Write a function that takes a word (upside down) as input and returns the number entered into the calculator.\r\n\r\nThis problem is related to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3018-calculator-spelling-numbers-to-letters Problem 3018\u003e.","description_html":"\u003cp\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\u003c/p\u003e\u003cul\u003e\u003cli\u003e0 = O\u003c/li\u003e\u003cli\u003e1 = I\u003c/li\u003e\u003cli\u003e2 = Z\u003c/li\u003e\u003cli\u003e3 = E\u003c/li\u003e\u003cli\u003e4 = h\u003c/li\u003e\u003cli\u003e5 = S\u003c/li\u003e\u003cli\u003e6 = g\u003c/li\u003e\u003cli\u003e7 = L\u003c/li\u003e\u003cli\u003e8 = B\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThere are a few other options, but we'll stick with these. If the word has a trailing O, the number will need a decimal point to produce a leading zero. Write a function that takes a word (upside down) as input and returns the number entered into the calculator.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3018-calculator-spelling-numbers-to-letters\"\u003eProblem 3018\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n] = calc_spell_num(word)\r\n\r\nn = str2num(word);\r\n\r\nend\r\n","test_suite":"%%\r\nn = 35007;\r\nword = 'LOOSE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 77345;\r\nword = 'ShELL';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 36138;\r\nword = 'BEIgE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 378806;\r\nword = 'gOBBLE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 376006;\r\nword = 'gOOgLE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 57738461375;\r\nword = 'SLEIghBELLS';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 0.7734;\r\nword = 'hELLO';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 53045;\r\nword = 'ShOES';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 771;\r\nword = 'ILL';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 345;\r\nword = 'ShE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 7735;\r\nword = 'SELL';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nind = randi(4);\r\nn_arr = [36138 707 7714 57738];\r\nn = n_arr(ind);\r\nword_arr = {'BEIgE','LOL','hILL','BELLS'};\r\nword = word_arr{ind};\r\nassert(isequal(calc_spell_num(word),n))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":68,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-14T22:18:14.000Z","updated_at":"2026-03-23T20:41:48.000Z","published_at":"2015-02-14T22:18:14.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e0 = O\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1 = I\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2 = Z\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e3 = E\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e4 = h\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e5 = S\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e6 = g\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e7 = L\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e8 = B\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThere are a few other options, but we'll stick with these. If the word has a trailing O, the number will need a decimal point to produce a leading zero. Write a function that takes a word (upside down) as input and returns the number entered into the calculator.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3018-calculator-spelling-numbers-to-letters\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3018\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3051,"title":"Scrabble Scores - 6","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you will be provided with a character matrix representing a completed game of Scrabble. Write a function to calculate and return the total score for the entire board. Don't worry about double counting of letters or words due to tile placement—that will come in a subsequent problem. As an example, suppose you are given the following board (this is test case 1):\r\n\r\n   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere   \r\n\r\nthe word cat scores 3+1+1 = 5, poet scores 3+1+1+1 = 6, there scores 1+4+1+1+1 = 8. The remaining letters (itc, p, and l) score 1+1+3, 3, and 1 which total 9 all together (since we're not double counting letters yet). The sum total is 5+6+8+9 = 28.\r\n\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 5 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5 Multiplayer word-set scoring\u003e. Next problem: 7 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7 Multiplayer board scoring\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a character matrix representing a completed game of Scrabble. Write a function to calculate and return the total score for the entire board. Don't worry about double counting of letters or words due to tile placement—that will come in a subsequent problem. As an example, suppose you are given the following board (this is test case 1):\u003c/p\u003e\u003cpre\u003e   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere   \u003c/pre\u003e\u003cp\u003ethe word cat scores 3+1+1 = 5, poet scores 3+1+1+1 = 6, there scores 1+4+1+1+1 = 8. The remaining letters (itc, p, and l) score 1+1+3, 3, and 1 which total 9 all together (since we're not double counting letters yet). The sum total is 5+6+8+9 = 28.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 5 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5\"\u003eMultiplayer word-set scoring\u003c/a\u003e. Next problem: 7 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7\"\u003eMultiplayer board scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_6(board)\r\n\r\nscore = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nboard = [\r\n\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   ';\r\n];\r\nscore = 28;\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%%\r\nboard = [\r\n\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    ';\r\n];\r\nscore = 51;\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' what   y ';\r\n'    h  do ';\r\n'  this  um';\r\n' l  n    a';\r\n' of keen t';\r\n' o   e   l';\r\n' problem a';\r\n'      noob';\r\n];\r\nscore = 72;\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n' e    it l';\r\n' e    v  i';\r\n' please  k';\r\n'      node';\r\n];\r\nscore = 56;\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%%\r\nboard = [\r\n\r\n'c    flummoxes zither';\r\n'al    o      e e    e';\r\n'ba  hunting  eerie  b';\r\n'ab  a g   e    o    e';\r\n'lo  n     m g       l';\r\n' r  g      responses ';\r\n'random      n    u u ';\r\n' t  v   c  below p r ';\r\n'convention  r    e f ';\r\n' r  r   n   a   areas';\r\n' y      v c t    i c ';\r\n'   o  philosophy o em';\r\n'travel  n n r    r  e';\r\n'   e    c t         e';\r\n' word   i a    writer';\r\n'   t    n c    o    l';\r\n'p fortnight   rock  y';\r\n'i  n            h    ';\r\n'novelty m concatenate';\r\n'c e  o  a    a  s   g';\r\n'heterogeneousness   g';\r\n];\r\nscore = 364;\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\ncase 1\r\nboard = [\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   '];\r\nscore = 28;\r\ncase 2\r\nboard = [\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    '];\r\nscore = 51;\r\ncase 3\r\nboard = [\r\n' what   y ';\r\n'  e h  do ';\r\n'  this  um';\r\n' of n    a';\r\n'    keen t';\r\n'     e   l';\r\n' problem a';\r\n'      noob'];\r\nscore = 71;\r\ncase 4\r\nboard = [\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n'      it l';\r\n'      v  i';\r\n' please  k';\r\n'      node'];\r\nscore = 54;\r\nend\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%% anti-cheating test case (again)\r\nind = randi(4);\r\nswitch ind\r\ncase 1\r\nboard = [\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   '];\r\nscore = 28;\r\ncase 2\r\nboard = [\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    '];\r\nscore = 51;\r\ncase 3\r\nboard = [\r\n' what   y ';\r\n'  e h  do ';\r\n'  this  um';\r\n' of n    a';\r\n'    keen t';\r\n'     e   l';\r\n' problem a';\r\n'      noob'];\r\nscore = 71;\r\ncase 4\r\nboard = [\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n'      it l';\r\n'      v  i';\r\n' please  k';\r\n'      node'];\r\nscore = 54;\r\nend\r\nassert(isequal(scrabble_scores_6(board),score))\r\n\r\n%% anti-cheating test case (and a third time, to lower the chance of getting lucky)\r\nind = randi(4);\r\nswitch ind\r\ncase 1\r\nboard = [\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   '];\r\nscore = 28;\r\ncase 2\r\nboard = [\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    '];\r\nscore = 51;\r\ncase 3\r\nboard = [\r\n' what   y ';\r\n'  e h  do ';\r\n'  this  um';\r\n' of n    a';\r\n'    keen t';\r\n'     e   l';\r\n' problem a';\r\n'      noob'];\r\nscore = 71;\r\ncase 4\r\nboard = [\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n'      it l';\r\n'      v  i';\r\n' please  k';\r\n'      node'];\r\nscore = 54;\r\nend\r\nassert(isequal(scrabble_scores_6(board),score))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":34,"test_suite_updated_at":"2015-02-28T06:29:28.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-02-28T04:41:43.000Z","updated_at":"2026-04-02T20:14:54.000Z","published_at":"2015-02-28T04:41:43.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a character matrix representing a completed game of Scrabble. Write a function to calculate and return the total score for the entire board. Don't worry about double counting of letters or words due to tile placement—that will come in a subsequent problem. As an example, suppose you are given the following board (this is test case 1):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   cat  \\n i  p   \\n t  poet\\n c  l   \\nthere]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethe word cat scores 3+1+1 = 5, poet scores 3+1+1+1 = 6, there scores 1+4+1+1+1 = 8. The remaining letters (itc, p, and l) score 1+1+3, 3, and 1 which total 9 all together (since we're not double counting letters yet). The sum total is 5+6+8+9 = 28.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 5 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer word-set scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 7 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer board scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3082,"title":"Scrabble Scores - 10","description":"This problem is very similar to the previous problem. Here, you are provided a letter of an existing word on the board from which you will play a word. The letter can reside anywhere (first to last) within the word you are playing. Write a function to find the highest scoring word, provided the letter you are building off of and the letters on your tray.\r\n\r\nRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the starting letter and the letters on your tray. 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).\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 9 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9 Word score optimization (fixed first letter)\u003e. Next problem: 11 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11 Word score optimization (known letter) \u0026 multipliers\u003e.","description_html":"\u003cp\u003eThis problem is very similar to the previous problem. Here, you are provided a letter of an existing word on the board from which you will play a word. The letter can reside anywhere (first to last) within the word you are playing. Write a function to find the highest scoring word, provided the letter you are building off of and the letters on your tray.\u003c/p\u003e\u003cp\u003eRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the starting letter and the letters on your tray. 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).\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 9 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9\"\u003eWord score optimization (fixed first letter)\u003c/a\u003e. Next problem: 11 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\"\u003eWord score optimization (known letter) \u0026 multipliers\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score,max_word] = scrabble_scores_10(words,existing_letter)\r\n\r\nscore = 0;\r\nmax_word = {''};\r\n\r\nend\r\n","test_suite":"%\r\nexisting_letter = 's'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nmax_score_corr = 12;\r\nmax_word_corr = {'atheism','hamlets'};\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nexisting_letter = 't'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\nmax_score_corr = 8;\r\nmax_word_corr = {'lentoid','tendril','trindle'};\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nexisting_letter = 'n'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\nmax_score_corr = 14;\r\nmax_word_corr = {'axmen'};\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nexisting_letter = 'z'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'aehcmdi'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\nmax_score_corr = 19;\r\nmax_word_corr = {'zaideh'};\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\texisting_letter = 's';\r\n\t\twords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'atheism','hamlets'};\r\n\tcase 2\r\n\t\texisting_letter = 't';\r\n\t\twords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\tmax_score_corr = 8;\r\n\t\tmax_word_corr = {'lentoid','tendril','trindle'};\r\n\tcase 3\r\n\t\texisting_letter = 'n';\r\n\t\twords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\n\t\tmax_score_corr = 14;\r\n\t\tmax_word_corr = {'axmen'};\r\n\tcase 4\r\n\t\texisting_letter = 'z';\r\n\t\twords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\n\t\tmax_score_corr = 19;\r\n\t\tmax_word_corr = {'zaideh'};\r\nend\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\texisting_letter = 's';\r\n\t\twords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'atheism','hamlets'};\r\n\tcase 2\r\n\t\texisting_letter = 't';\r\n\t\twords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\tmax_score_corr = 8;\r\n\t\tmax_word_corr = {'lentoid','tendril','trindle'};\r\n\tcase 3\r\n\t\texisting_letter = 'n';\r\n\t\twords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\n\t\tmax_score_corr = 14;\r\n\t\tmax_word_corr = {'axmen'};\r\n\tcase 4\r\n\t\texisting_letter = 'z';\r\n\t\twords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\n\t\tmax_score_corr = 19;\r\n\t\tmax_word_corr = {'zaideh'};\r\nend\r\n[max_score,max_word] = scrabble_scores_10(words,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":7,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":"2015-03-17T13:21:23.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-14T18:30:00.000Z","updated_at":"2026-04-02T20:19:50.000Z","published_at":"2015-03-14T18:30:35.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is very similar to the previous problem. Here, you are provided a letter of an existing word on the board from which you will play a word. The letter can reside anywhere (first to last) within the word you are playing. Write a function to find the highest scoring word, provided the letter you are building off of and the letters on your tray.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the starting letter and the letters on your tray. 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).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 9 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (fixed first letter)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 11 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (known letter) \u0026amp; multipliers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3050,"title":"Scrabble Scores - 5","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you will be provided with a set of words for each player in a game of Scrabble. The number of players may vary from two to four. The word set for each player will be provided in a cell array of strings; you'll need to use nargin and varargin to read in varying numbers of cell arrays for each test case. Write a function to calculate and return the total score for each player in a vector equal in length to the number of players.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 4 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4 Word-set multiplier scoring\u003e. Next problem: 6 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6 Board scoring\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a set of words for each player in a game of Scrabble. The number of players may vary from two to four. The word set for each player will be provided in a cell array of strings; you'll need to use nargin and varargin to read in varying numbers of cell arrays for each test case. Write a function to calculate and return the total score for each player in a vector equal in length to the number of players.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 4 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\"\u003eWord-set multiplier scoring\u003c/a\u003e. Next problem: 6 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6\"\u003eBoard scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_5(varargin)\r\n\r\nscore = zeros(1,nargin);\r\n\r\nend\r\n","test_suite":"%%\r\nwords1 = {'hello','there','fellow','matlab','users'};\r\nwords2 = {'what','do','you','think','of','this','problem'};\r\nwords3 = {'if','you','like','it','please','give','it','a','like'};\r\nscore = [43 56 48];\r\nassert(isequal(scrabble_scores_5(words1,words2,words3),score))\r\n\r\n%%\r\nwords1 = {'zither','quandry','flummox','wealthy','amalgam'};\r\nwords2 = {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\nwords3 = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\nwords4 = {'perspicacious','yes','zero','quizzical','no'};\r\nscore = [87 94 70 80];\r\nassert(isequal(scrabble_scores_5(words1,words2,words3,words4),score))\r\n\r\n%%\r\nwords1 = {'one','two','three','four','five'};\r\nwords2 = {'six','seven','eight','nine','ten'};\r\nscore = [34 34];\r\nassert(isequal(scrabble_scores_5(words1,words2),score))\r\n\r\n%%\r\nwords1 = {'random','word','generator','responses','below'};\r\nwords2 = {'contact','laboratory','overtone','writer','philosophy'};\r\nwords3 = {'hunting','convention','surface','superior','travel'};\r\nwords4 = {'convincing','hangover','fortnight','long','novelty'};\r\nscore = [48 69 57 67];\r\nassert(isequal(scrabble_scores_5(words1,words2,words3,words4),score))\r\n\r\n%%\r\nwords = { {'random','word','generator','responses','below'};\r\n {'contact','laboratory','overtone','writer','philosophy'};\r\n {'hunting','convention','surface','superior','travel'};\r\n {'convincing','hangover','fortnight','long','novelty'}; };\r\nscore = [48 69 57 67];\r\nind1 = randi(4);\r\nind2 = randi(4);\r\nassert(isequal(scrabble_scores_5(words{ind1},words{ind2}),[score(ind1) score(ind2)]))\r\n\r\n%%\r\nwords = { {'zither','quandry','flummox','wealthy','amalgam'};\r\n {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\n {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\n {'perspicacious','yes','zero','quizzical','no'}; };\r\nscore = [87 94 70 80];\r\nind1 = randi(4);\r\nind2 = randi(4);\r\nassert(isequal(scrabble_scores_5(words{ind1},words{ind2}),[score(ind1) score(ind2)]))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":36,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":40,"created_at":"2015-02-28T03:40:58.000Z","updated_at":"2026-04-02T20:13:53.000Z","published_at":"2015-02-28T03:40:58.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a set of words for each player in a game of Scrabble. The number of players may vary from two to four. The word set for each player will be provided in a cell array of strings; you'll need to use nargin and varargin to read in varying numbers of cell arrays for each test case. Write a function to calculate and return the total score for each player in a vector equal in length to the number of players.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 4 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord-set multiplier scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 6 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eBoard scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3062,"title":"Scrabble Scores - 9","description":"After developing a sophisticated Scrabble scoring routine, it's time to write an optimization routine for single-word scoring. The point distribution for English is provided \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e.\r\n\r\nFor this problem, you are provided the starting letter (from an existing word on the board) from which you will play a word. For this problem, we'll assume that that's the first letter of your new word.\r\n\r\nRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the letters on your tray. Write a function to determine which word would provide the highest score. Also, provide the word(s) that achieve that score in a cell array. See the test suite for examples.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 8 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8 Multiplayer multiplier board scoring\u003e. Next problem: 10 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10 Word score optimization (given letter)\u003e.","description_html":"\u003cp\u003eAfter developing a sophisticated Scrabble scoring routine, it's time to write an optimization routine for single-word scoring. The point distribution for English is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eFor this problem, you are provided the starting letter (from an existing word on the board) from which you will play a word. For this problem, we'll assume that that's the first letter of your new word.\u003c/p\u003e\u003cp\u003eRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the letters on your tray. Write a function to determine which word would provide the highest score. Also, provide the word(s) that achieve that score in a cell array. See the test suite for examples.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 8 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8\"\u003eMultiplayer multiplier board scoring\u003c/a\u003e. Next problem: 10 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\"\u003eWord score optimization (given letter)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [max_score,max_word] = scrabble_scores_9(words,first_letter)\r\n\r\nmax_score = 0;\r\nmax_word = '';\r\n\r\nend\r\n","test_suite":"%%\r\nfirst_letter = 's'; %the word must start with this letter, which is in an already played word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix)\r\nwords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nmax_score_corr = 10;\r\nmax_word_corr = {'shame','smith'};\r\n[max_score,max_word] = scrabble_scores_9(words,first_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_letter = 't'; %the word must start with this letter, which is in an already played word\r\ntray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix)\r\nwords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\nmax_score_corr = 8;\r\nmax_word_corr = {'tendril','trindle'};\r\n[max_score,max_word] = scrabble_scores_9(words,first_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_letter = 'n'; %the word must start with this letter, which is in an already played word\r\ntray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix)\r\nwords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\nmax_score_corr = 8;\r\nmax_word_corr = {'named','nomad','novae'};\r\n[max_score,max_word] = scrabble_scores_9(words,first_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_letter = 'z'; %the word must start with this letter, which is in an already played word\r\ntray_letters = 'aehcmdi'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix)\r\nwords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\nmax_score_corr = 19;\r\nmax_word_corr = {'zaideh'};\r\n[max_score,max_word] = scrabble_scores_9(words,first_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tfirst_letter = 's';\r\n\t\twords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\n\t\tmax_score_corr = 10;\r\n\t\tmax_word_corr = {'shame','smith'};\r\n\tcase 2\r\n\t\tfirst_letter = 't';\r\n\t\twords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\tmax_score_corr = 8;\r\n\t\tmax_word_corr = {'tendril','trindle'};\r\n\tcase 3\r\n\t\tfirst_letter = 'n';\r\n\t\twords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\n\t\tmax_score_corr = 8;\r\n\t\tmax_word_corr = {'named','nomad','novae'};\r\n\tcase 4\r\n\t\tfirst_letter = 'z';\r\n\t\twords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\n\t\tmax_score_corr = 19;\r\n\t\tmax_word_corr = {'zaideh'};\r\nend\r\n[max_score,max_word] = scrabble_scores_9(words,first_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-04T02:02:45.000Z","updated_at":"2026-04-02T20:19:03.000Z","published_at":"2015-03-04T02:02:45.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAfter developing a sophisticated Scrabble scoring routine, it's time to write an optimization routine for single-word scoring. The point distribution for English is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you are provided the starting letter (from an existing word on the board) from which you will play a word. For this problem, we'll assume that that's the first letter of your new word.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRather than having to test all the possible permutations against a dictionary, you will be provided a cell array of strings containing all possible words based on the letters on your tray. Write a function to determine which word would provide the highest score. Also, provide the word(s) that achieve that score in a cell array. See the test suite for examples.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 8 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer multiplier board scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 10 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (given letter)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44816,"title":"Word Distance - Average Sort","description":"Based on the method of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44815-word-distance-sum this problem\u003e, write a function to calculate the letter distance for a set of words and then return the sorted set of words based on their distances, in ascending order. However, their distances will now be normalized by the number of characters in each word. For example, if \r\n\r\n str_arr = {'jazz','cab','tree'}\r\n\r\nthen \r\n\r\n d = [(9+25+0)/4, (2+1)/3, (2+13+0)/4] = [34/4, 3/3, 15/4] = [8.5, 1, 3.75]\r\n\r\nwhich would result in the following sorted order:\r\n\r\n str_arr_sort = {'cab','tree','jazz'}\r\n\r\nRemember that the method is case insensitive. See the test suite for examples.","description_html":"\u003cp\u003eBased on the method of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44815-word-distance-sum\"\u003ethis problem\u003c/a\u003e, write a function to calculate the letter distance for a set of words and then return the sorted set of words based on their distances, in ascending order. However, their distances will now be normalized by the number of characters in each word. For example, if\u003c/p\u003e\u003cpre\u003e str_arr = {'jazz','cab','tree'}\u003c/pre\u003e\u003cp\u003ethen\u003c/p\u003e\u003cpre\u003e d = [(9+25+0)/4, (2+1)/3, (2+13+0)/4] = [34/4, 3/3, 15/4] = [8.5, 1, 3.75]\u003c/pre\u003e\u003cp\u003ewhich would result in the following sorted order:\u003c/p\u003e\u003cpre\u003e str_arr_sort = {'cab','tree','jazz'}\u003c/pre\u003e\u003cp\u003eRemember that the method is case insensitive. See the test suite for examples.\u003c/p\u003e","function_template":"function d = word_distance_sort(str_arr)\r\n d = 1;\r\nend","test_suite":"%%\r\nassert(isequal(word_distance_sort({'jazz','cab','tree'}),{'cab','tree','jazz'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'first','second','third'}),{'first','second','third'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'the','longest','words','supercede','some','of','the','shortest'}), ...\r\n\t{'some','longest','of','the','the','supercede','shortest','words'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'one','TWO','Three','FouR','fiVe','six','sEvEn','EiGHt','NINe','ten'}), ...\r\n\t{'one','TWO','EiGHt','FouR','NINe','Three','ten','fiVe','six','sEvEn'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'Why','is','it','that','this','does','not','work','as','expected'}), ...\r\n\t{'not','work','is','it','this','does','as','expected','that','Why'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'set','of','very','short','words','for','this','test','case'}), ...\r\n\t{'for','of','short','this','test','words','case','very','set'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'iron','zinc','carbon','molybdenum','praseodymium','silicon'}), ...\r\n\t{'iron','silicon','molybdenum','carbon','zinc','praseodymium'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'crazier','craziest','crazy'}), ...\r\n\t{'crazy','craziest','crazier'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'this','test','case','with','only','four','each','word'}), ...\r\n\t{'each','only','four','this','word','test','case','with'}))\r\n\r\n%%\r\nassert(isequal(word_distance_sort({'largest','smallest','sourest','sweetest'}), ...\r\n\t{'sourest','smallest','largest','sweetest'}))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":15,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":65,"created_at":"2019-01-02T15:43:24.000Z","updated_at":"2025-11-21T14:57:55.000Z","published_at":"2019-01-09T15:06:52.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased on the method of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44815-word-distance-sum\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ethis problem\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, write a function to calculate the letter distance for a set of words and then return the sorted set of words based on their distances, in ascending order. However, their distances will now be normalized by the number of characters in each word. For example, if\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ str_arr = {'jazz','cab','tree'}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ d = [(9+25+0)/4, (2+1)/3, (2+13+0)/4] = [34/4, 3/3, 15/4] = [8.5, 1, 3.75]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhich would result in the following sorted order:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ str_arr_sort = {'cab','tree','jazz'}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember that the method is case insensitive. See the test suite for examples.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3049,"title":"Scrabble Scores - 4","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings; the bonus squares will be provided in a two-level cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\r\n\r\n* 'DL' = double letter\r\n* 'DW' = double word\r\n* 'TL' = triple letter\r\n* 'TW' = triple word\r\n* 'QL' = quadruple letter\r\n* 'QW' = quadruple word\r\n\r\nFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026 TW = *6).\r\n\r\nAs an example, if the word were 'matlab' and the multiplier cell array was \r\n\r\n  {'','DW','','','','DL'}\r\n\r\n\r\nthen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\r\n\r\nThis is an old version of problem 4 in this series. It has been revised and is available here: \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4 Word-set multiplier scoring\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings; the bonus squares will be provided in a two-level cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\u003c/p\u003e\u003cul\u003e\u003cli\u003e'DL' = double letter\u003c/li\u003e\u003cli\u003e'DW' = double word\u003c/li\u003e\u003cli\u003e'TL' = triple letter\u003c/li\u003e\u003cli\u003e'TW' = triple word\u003c/li\u003e\u003cli\u003e'QL' = quadruple letter\u003c/li\u003e\u003cli\u003e'QW' = quadruple word\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026 TW = *6).\u003c/p\u003e\u003cp\u003eAs an example, if the word were 'matlab' and the multiplier cell array was\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e{'','DW','','','','DL'}\r\n\u003c/pre\u003e\u003cp\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\u003c/p\u003e\u003cp\u003eThis is an old version of problem 4 in this series. It has been revised and is available here: \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\"\u003eWord-set multiplier scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_4(words,mult)\r\n\r\nscore = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nwords = {'hello','there','fellow','matlab','users'};\r\nmult = {{'DW','','','','DL'} {'DW','','','','DL'} {'','DW','','','','DL'} {'','DW','','','','DL'} {'DW','','','','DL'}};\r\nscore = 106;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%%\r\nwords = {'what','do','you','think','of','this','problem'};\r\nmult = {{'','DW','',''}; {'',''}; {'','DW',''}; {'','DW','','','TL'}; {'',''}; {'','DW','',''}; {'TL','','','DW','','','TL'}};\r\nscore = 148;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%%\r\nwords = {'if','you','like','it','please','give','it','a','like'};\r\nmult = {{'','DW'}; {'','','QW'}; {'','DW','',''}; {'',''}; {'','DW','','','TL',''}; {'','DW','',''}; {'TL',''}; {''}; {'DW','','','TL'}};\r\nscore = 113;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%%\r\nwords = {'zither','quandry','flummox','wealthy','amalgam'};\r\nmult = {{'','DW','','','','DW'}; {'QL','','','','','DW',''}; {'','DW','','','','DW',''}; {'','DW','','','','DW',''}; {'','DW','','','','DW',''}; };\r\nscore = 368;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%%\r\nwords = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\nmult = {{'TL','','','','TL','','','','TW','','','','QW'}; {'','','','TL','','','','TW','','','','QW'}; {'TL','','','','TL','','','','TW','',''}; {'TL','','','','TL',''}; {'',''}; };\r\nscore = 690;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%%\r\nwords = {'perspicacious','yes','zero','quizzical','no'};\r\nmult = {{'TL','','','','TL','','','','TW','','','','QW'}; {'','',''}; {'TL','','',''}; {'TL','','','','TL','','','TW',''}; {'',''}; };\r\nscore = 671;\r\nassert(isequal(scrabble_scores_4(words,mult),score))\r\n\r\n%% pangram test to help ensure letters scores are correctly assigned\r\nwords = {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\nmult = {{'TL','',''}; {'','TL','','',''}; {'TW','','','','QW'}; {'','',''}; {'TL','','','','QL'}; {'TL','','',''}; {'TL'}; {'','','TW',''}; {'','','QW'}; };\r\nscore = 278;\r\nassert(isequal(scrabble_scores_4(words,mult),score))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":15,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-02-28T03:14:55.000Z","updated_at":"2025-11-01T19:19:19.000Z","published_at":"2015-02-28T03:14:55.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings; the bonus squares will be provided in a two-level cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'DL' = double letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'DW' = double word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'TL' = triple letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'TW' = triple word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'QL' = quadruple letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'QW' = quadruple word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026amp; TW =\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e *\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e6).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, if the word were 'matlab' and the multiplier cell array was\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[{'','DW','','','','DL'}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis is an old version of problem 4 in this series. It has been revised and is available here:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord-set multiplier scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3048,"title":"Scrabble Scores - 3","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you will be provided with a word and the accompanying bonus squares that the word might have covered (in a cell array of strings). Write a function to calculate the total score for the word using the multipliers. The multipliers are as follows:\r\n\r\n* 'DL' = double letter\r\n* 'DW' = double word\r\n* 'TL' = triple letter\r\n* 'TW' = triple word\r\n* 'QL' = quadruple letter\r\n* 'QW' = quadruple word\r\n\r\nFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026 TW = *6).\r\n\r\nAs an example, if the word were 'matlab' and the multiplier cell array was \r\n\r\n  {'','DW','','','','DL'}\r\n\r\n\r\nthen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 2 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3047-scrabble-scores-2 Word-set scoring\u003e. Next problem: 4 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4 Word-set multiplier scoring\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a word and the accompanying bonus squares that the word might have covered (in a cell array of strings). Write a function to calculate the total score for the word using the multipliers. The multipliers are as follows:\u003c/p\u003e\u003cul\u003e\u003cli\u003e'DL' = double letter\u003c/li\u003e\u003cli\u003e'DW' = double word\u003c/li\u003e\u003cli\u003e'TL' = triple letter\u003c/li\u003e\u003cli\u003e'TW' = triple word\u003c/li\u003e\u003cli\u003e'QL' = quadruple letter\u003c/li\u003e\u003cli\u003e'QW' = quadruple word\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026 TW = *6).\u003c/p\u003e\u003cp\u003eAs an example, if the word were 'matlab' and the multiplier cell array was\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e{'','DW','','','','DL'}\r\n\u003c/pre\u003e\u003cp\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 2 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3047-scrabble-scores-2\"\u003eWord-set scoring\u003c/a\u003e. Next problem: 4 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\"\u003eWord-set multiplier scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_3(word,mult)\r\n\r\nscore = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nword = 'matlab';\r\nmult = {'','DW','','','','DL'};\r\nscore = 26;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = 'problem';\r\nmult = {'','','','','','',''};\r\nscore = 13;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = 'zither';\r\nmult = {'','DW','','','','DW'};\r\nscore = 72;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = 'quandry';\r\nmult = {'TL','','','','TL','',''};\r\nscore = 44;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = 'concatenates';\r\nmult = {'TW','','','DL','','','','TW','','','','DL'};\r\nscore = 180;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = 'heterogeneousness';\r\nmult = {'QW','','','DL','','','','TW','','','DL','','','TW','','',''};\r\nscore = 828;\r\nassert(isequal(scrabble_scores_3(word,mult),score))\r\n\r\n%%\r\nword = {'hello','donut','cheat','shape','quote'};\r\nmult = {'QW','','','DL',''};\r\nscore = [36 28 44 52 60];\r\nind = randi(5);\r\nassert(isequal(scrabble_scores_3(word{ind},mult),score(ind)))\r\n\r\n%%\r\nword = {'hello','donut','cheat','shape','quote'};\r\nmult = {'QL','','','','DW'};\r\nscore = [40 24 38 26 88];\r\nind = randi(5);\r\nassert(isequal(scrabble_scores_3(word{ind},mult),score(ind)))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":40,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":40,"created_at":"2015-02-26T04:46:46.000Z","updated_at":"2026-04-02T20:11:50.000Z","published_at":"2015-02-26T04:46:46.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a word and the accompanying bonus squares that the word might have covered (in a cell array of strings). Write a function to calculate the total score for the word using the multipliers. The multipliers are as follows:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'DL' = double letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'DW' = double word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'TL' = triple letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'TW' = triple word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'QL' = quadruple letter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'QW' = quadruple word\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor those not familiar with QL and QW, those were introduced in Super Scrabble. Also, remember that the DL, TL, and QL multipliers take effect before the DW, TW, and QW multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., DW \u0026amp; TW =\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e *\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e6).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, if the word were 'matlab' and the multiplier cell array was\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[{'','DW','','','','DL'}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 2 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3047-scrabble-scores-2\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord-set scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 4 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3081-scrabble-scores-4\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord-set multiplier scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3081,"title":"Scrabble Scores - 4","description":"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.)\r\n\r\nFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\r\n\r\n * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\r\n\r\nFor those not familiar with quadruple word (Q) and quadruple letter (q), those were introduced in Super Scrabble. Also, remember that the d, t, and q multipliers take effect before the D, T, and Q multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., D \u0026 T = *6).\r\n\r\nAs an example, if the word were 'matlab' and the multiplier string array was\r\n\r\n  [' ','D',' ',' ',' ','d'] (or ' D   d')\r\n\r\nthen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 3 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3 Single-word multiplier scoring\u003e. Next problem: 5 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5 Multiplayer word-set scoring\u003e.","description_html":"\u003cp\u003eThis 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.)\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\u003c/p\u003e\u003cpre\u003e * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\u003c/pre\u003e\u003cp\u003eFor those not familiar with quadruple word (Q) and quadruple letter (q), those were introduced in Super Scrabble. Also, remember that the d, t, and q multipliers take effect before the D, T, and Q multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., D \u0026 T = *6).\u003c/p\u003e\u003cp\u003eAs an example, if the word were 'matlab' and the multiplier string array was\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e[' ','D',' ',' ',' ','d'] (or ' D   d')\r\n\u003c/pre\u003e\u003cp\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 3 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3\"\u003eSingle-word multiplier scoring\u003c/a\u003e. Next problem: 5 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5\"\u003eMultiplayer word-set scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_4_rev(words,mult)\r\n\r\nscore = 0;\r\n\r\nend\r\n","test_suite":"%\r\nwords = {'hello','there','fellow','matlab','users'};\r\nmult = {'D   d','D   d',' D   d',' D   d','D   d'};\r\nscore = 106;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%%\r\nwords = {'what','do','you','think','of','this','problem'};\r\nmult = {' D  ','  ',' D ',' D  t','  ',' D  ','t  D  t'};\r\nscore = 148;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%%\r\nwords = {'if','you','like','it','please','give','it','a','like'};\r\nmult = {' D','  Q',' D  ','  ',' D  t ',' D  ','t ',' ','D  t'};\r\nscore = 113;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%%\r\nwords = {'zither','quandry','flummox','wealthy','amalgam'};\r\nmult = {' D   D','q    D ',' D   D ',' D   D ',' D   D '};\r\nscore = 368;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%%\r\nwords = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\nmult = {'t   t   T   Q','   t   T   Q','t   t   T  ','t   t ','  '};\r\nscore = 690;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%%\r\nwords = {'perspicacious','yes','zero','quizzical','no'};\r\nmult = {'t   t   T   Q','   ','t   ','t   t  T ','  '};\r\nscore = 671;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%% pangram test to help ensure letters scores are correctly assigned\r\nwords = {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\nmult = {'t  ',' t   ','T   Q','   ','t   q','t   ','t','  T ','  Q'};\r\nscore = 278;\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%% anti-cheating case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\twords = {'hello','there','fellow','matlab','users'};\r\n\t\tmult = {'D   d','D   d',' D   d',' D   d','D   d'};\r\n\t\tscore = 106;\r\n\tcase 2\r\n\t\twords = {'if','you','like','it','please','give','it','a','like'};\r\n\t\tmult = {' D','  Q',' D  ','  ',' D  t ',' D  ','t ',' ','D  t'};\r\n\t\tscore = 113;\r\n\tcase 3\r\n\t\twords = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\n\t\tmult = {'t   t   T   Q','   t   T   Q','t   t   T  ','t   t ','  '};\r\n\t\tscore = 690;\r\n\tcase 4\r\n\t\twords = {'the','quick','brown','fox','jumps','over','a','lazy','dog'};\r\n\t\tmult = {'t  ',' t   ','T   Q','   ','t   q','t   ','t','  T ','  Q'};\r\n\t\tscore = 278;\r\nend\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))\r\n\r\n%% anti-cheating case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\twords = {'what','do','you','think','of','this','problem'};\r\n\t\tmult = {' D  ','  ',' D ',' D  t','  ',' D  ','t  D  t'};\r\n\t\tscore = 148;\r\n\tcase 2\r\n\t\twords = {'perspicacious','yes','zero','quizzical','no'};\r\n\t\tmult = {'t   t   T   Q','   ','t   ','t   t  T ','  '};\r\n\t\tscore = 671;\r\n\tcase 3\r\n\t\twords = {'heterogeneous','homogenously','concatenate','thusly','hi'};\r\n\t\tmult = {'t   t   T   Q','   t   T   Q','t   t   T  ','t   t ','  '};\r\n\t\tscore = 690;\r\n\tcase 4\r\n\t\twords = {'zither','quandry','flummox','wealthy','amalgam'};\r\n\t\tmult = {' D   D','q    D ',' D   D ',' D   D ',' D   D '};\r\n\t\tscore = 368;\r\nend\r\nassert(isequal(scrabble_scores_4_rev(words,mult),score))","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":34,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-14T18:10:41.000Z","updated_at":"2026-04-02T20:12:58.000Z","published_at":"2015-03-14T18:10:41.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis 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.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a set of words and the accompanying bonus squares that each word covered. The words will be provided in a cell array of strings. Write a function to calculate the total score for the set of words using the multipliers. The multipliers are as follows:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ * D: double word\\n * T: triple word\\n * Q: quadruple word\\n * d: double letter\\n * t: triple letter\\n * q: quadruple letter]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor those not familiar with quadruple word (Q) and quadruple letter (q), those were introduced in Super Scrabble. Also, remember that the d, t, and q multipliers take effect before the D, T, and Q multipliers. Also, multiple word multipliers can be present, having a cumulative effect (e.g., D \u0026amp; T =\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e *\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e6).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, if the word were 'matlab' and the multiplier string array was\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[[' ','D',' ',' ',' ','d'] (or ' D   d')]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen the score would be (3 + 1 + 1 + 1 + 1 + 2*3)*2 = 26. Each word in the set should be scored in this manner and the total score summed.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 3 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3048-scrabble-scores-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSingle-word multiplier scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 5 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3050-scrabble-scores-5\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer word-set scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":53960,"title":"Wordle","description":"Wordle is an english game where you need to guess a 5 letter word. For each guess you'll receive a feedback for the placement of each letter. If a letter is in the correct spot it will show as green, if a letter is in the word, but in the wrong spot it will show as yellow and if the letter is not present in the word it will show as black.\r\nFor this problem your inputs will be the target word and a guess, the output should be a vector corresponding to the guess word where there should be a -1 if the letter is not present in the target word, a 0 if the letter is present in the target word, but at the wrong spot, and a 1 if the letter is in the correct spot.\r\n\r\nExample:\r\nTarget Word: 'thing'\r\nGuess Word: 'write'\r\nOutput: [-1 -1 1 0 -1]\r\nAll inputs will be lower case and contain 5 letters.\r\nIf a letter appears more than once in the guess and only once in the target word then it should be considered correct only once. consider the correct letter the one in the correct spot if any, else the first occurence of the letter should be considered (see test cases 2,3, and 4 for examples)","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 387px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 193.5px; transform-origin: 407px 193.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://www.powerlanguage.co.uk/wordle/\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWordle\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e is an english game where you need to guess a 5 letter word. For each guess you'll receive a feedback for the placement of each letter. If a letter is in the correct spot it will show as green, if a letter is in the word, but in the wrong spot it will show as yellow and if the letter is not present in the word it will show as black.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor this problem your inputs will be the target word and a guess, the output should be a vector corresponding to the guess word where there should be a -1 if the letter is not present in the target word, a 0 if the letter is present in the target word, but at the wrong spot, and a 1 if the letter is in the correct spot.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eTarget Word: 'thing'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eGuess Word: 'write'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eOutput: [-1 -1 1 0 -1]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eAll inputs will be lower case and contain 5 letters.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eIf a letter appears more than once in the guess and only once in the target word then it should be considered correct only once. consider the correct letter the one in the correct spot if any, else the first occurence of the letter should be considered (see test cases 2,3, and 4 for examples)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = wordle(target,guess)\r\n  y =[0 0 0 0 0];\r\nend","test_suite":"%%\r\ntarget = 'prick';\r\nguess = 'thing';\r\ny_correct = [-1 -1 1 -1 -1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'carts';\r\nguess = 'sssss';\r\ny_correct = [-1 -1 -1 -1 1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'parts';\r\nguess = 'ssssp';\r\ny_correct = [0 -1 -1 -1 0];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'sides';\r\nguess = 'ksssk';\r\ny_correct = [-1 0 0 -1 -1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'write';\r\nguess = 'price';\r\ny_correct = [-1 1 1 -1 1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'heart';\r\nguess = 'lists';\r\ny_correct = [-1 -1 -1 0 -1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'blues';\r\nguess = 'purge';\r\ny_correct = [-1 0 -1 -1 0];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'perky';\r\nguess = 'pluck';\r\ny_correct = [1 -1 -1 -1 0];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'perky';\r\nguess = 'axiom';\r\ny_correct = [-1 -1 -1 -1 -1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'perky';\r\nguess = 'perks';\r\ny_correct = [1 1 1 1 -1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n%%\r\ntarget = 'mount';\r\nguess = 'mount';\r\ny_correct = [1 1 1 1 1];\r\nassert(isequal(wordle(target,guess),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":1766515,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":8,"test_suite_updated_at":"2022-01-28T14:57:59.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2022-01-21T15:14:48.000Z","updated_at":"2024-11-14T20:03:07.000Z","published_at":"2022-01-21T15:14:48.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.powerlanguage.co.uk/wordle/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWordle\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is an english game where you need to guess a 5 letter word. For each guess you'll receive a feedback for the placement of each letter. If a letter is in the correct spot it will show as green, if a letter is in the word, but in the wrong spot it will show as yellow and if the letter is not present in the word it will show as black.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem your inputs will be the target word and a guess, the output should be a vector corresponding to the guess word where there should be a -1 if the letter is not present in the target word, a 0 if the letter is present in the target word, but at the wrong spot, and a 1 if the letter is in the correct spot.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTarget Word: 'thing'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGuess Word: 'write'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: [-1 -1 1 0 -1]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAll inputs will be lower case and contain 5 letters.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf a letter appears more than once in the guess and only once in the target word then it should be considered correct only once. consider the correct letter the one in the correct spot if any, else the first occurence of the letter should be considered (see test cases 2,3, and 4 for examples)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44815,"title":"Word Distance - Sum","description":"Let's suppose that the distance of a word can be calculated by summing the differences between its letters, having assigned the letters of the alphabet to integers (a = 1, b = 2, ... z = 26). For example, if\r\n\r\n word = 'hello'\r\n\r\nthen the total distance would be \r\n\r\n abs(8–5) + abs(5–12) + abs(12–12) + abs(12–15) = 3 + 7 + 0 + 3 = 13.\r\n\r\nLet's also make this case insensitive (i.e., 'A' = 'a'). Write a function to return the distance for any word or set of words. See the test suite for examples.","description_html":"\u003cp\u003eLet's suppose that the distance of a word can be calculated by summing the differences between its letters, having assigned the letters of the alphabet to integers (a = 1, b = 2, ... z = 26). For example, if\u003c/p\u003e\u003cpre\u003e word = 'hello'\u003c/pre\u003e\u003cp\u003ethen the total distance would be\u003c/p\u003e\u003cpre\u003e abs(8–5) + abs(5–12) + abs(12–12) + abs(12–15) = 3 + 7 + 0 + 3 = 13.\u003c/pre\u003e\u003cp\u003eLet's also make this case insensitive (i.e., 'A' = 'a'). Write a function to return the distance for any word or set of words. See the test suite for examples.\u003c/p\u003e","function_template":"function d = word_distance_sum(str)\r\n d = 1;\r\nend","test_suite":"%%\r\nassert(isequal(word_distance_sum('hello'),13))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('Hello'),13))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('HELLO'),13))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('way'),46))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('Sway'),50))\r\n\r\n%%\r\n[d] = word_distance_sum({'hello','Sway'});\r\nassert(isequal(d(1),13))\r\nassert(isequal(d(2),50))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('Matlab'),51))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('aBCdEfghIJkLmNOPqrStUVwxyZ'),25))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('qwerty'),44))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('bead'),10))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('payday'),87))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('bookkeeper'),58))\r\n\r\n%%\r\n[d] = word_distance_sum({'one','TWO','Three','FouR','fiVe','six','sEvEn','EiGHt','NINe','ten'});\r\nassert(isequal(d(1),10))\r\nassert(isequal(d(2),11))\r\nassert(isequal(d(3),35))\r\nassert(isequal(d(4),18))\r\nassert(isequal(d(5),33))\r\nassert(isequal(d(6),25))\r\nassert(isequal(d(7),57))\r\nassert(isequal(d(8),19))\r\nassert(isequal(d(9),19))\r\nassert(isequal(d(10),24))\r\n\r\n%%\r\nassert(isequal(word_distance_sum('crazier'),91))","published":true,"deleted":false,"likes_count":4,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":185,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":65,"created_at":"2019-01-02T14:44:50.000Z","updated_at":"2026-03-30T18:05:29.000Z","published_at":"2019-01-02T14:44:50.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eLet's suppose that the distance of a word can be calculated by summing the differences between its letters, having assigned the letters of the alphabet to integers (a = 1, b = 2, ... z = 26). For example, if\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ word = 'hello']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen the total distance would be\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ abs(8–5) + abs(5–12) + abs(12–12) + abs(12–15) = 3 + 7 + 0 + 3 = 13.]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eLet's also make this case insensitive (i.e., 'A' = 'a'). Write a function to return the distance for any word or set of words. See the test suite for examples.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3097,"title":"Scrabble Scores - 12","description":"This problem builds directly off of Scrabble Scores - 10. 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. Write a function to find the highest scoring word, provided any letter from the existing word that you are building off of and the letters on your tray.\r\nRather 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).\r\nRelated problems:\r\nPrevious problem: 11 - Word score optimization (known letter \u0026 multipliers). Next problem: 13 - Word score optimization (first word \u0026 multipliers).","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 279px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 139.5px; transform-origin: 407px 139.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 104px 8px; transform-origin: 104px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem builds directly off of\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eScrabble Scores - 10\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 209px 8px; transform-origin: 209px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. 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. Write a function to find the highest scoring word, provided any letter from the existing word that you are building off of and the letters on your tray.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 105px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 52.5px; text-align: left; transform-origin: 384px 52.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 382.5px 8px; transform-origin: 382.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eRather 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).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 57.5px 8px; transform-origin: 57.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eRelated problems:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 71px 8px; transform-origin: 71px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ePrevious problem: 11 -\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWord score optimization (known letter \u0026amp; multipliers)\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 61.5px 8px; transform-origin: 61.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Next problem: 13 -\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3098-scrabble-scores-13\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWord score optimization (first word \u0026amp; multipliers)\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [score,max_word] = scrabble_scores_12(words, first_word)\r\n\r\nscore = 0;\r\nmax_word = {''};\r\n\r\nend\r\n","test_suite":"%%\r\nfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nwords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nwords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\nwords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\nwords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nmax_score_corr = 12;\r\nmax_word_corr = {'atheism','hamlets','hematal','thalami','thermal'};\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_word = 'thinning'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\nwords{2} = {'dhole','diner','drone','eloin','enrol','helio','heron','hider','hired','holed','honed','honer','horde','idler','indol','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','rhino','riled','ronde','dehorn','dinero','heroin','hinder','hoiden','holden','holder','holier','hondle','honied','horned','indole','ironed','neroli','roiled','rondel','hordein','inholder'};\r\nwords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\nwords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\nwords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{8} = {'deign','diner','dinge','dingo','dirge','dogie','doing','drone','eloin','enrol','gelid','genro','geoid','giron','glide','goner','gored','gride','grind','groin','idler','indol','ingle','irone','liger','lined','liner','lingo','loden','lodge','login','loner','longe','nerol','ogled','ogler','oiled','oiler','olden','older','oldie','olein','oriel','redon','reign','renig','reoil','ridge','riled','ronde','dinero','dinger','dingle','doling','dongle','eloign','engild','engird','eringo','gilder','girdle','girned','glider','golden','golder','ignore','indole','ironed','legion','linger','lodger','logier','longed','longer','neroli','reding','regild','region','ridgel','ringed','roiled','rondel','eroding','glenoid','gloried','godlier','groined','ignored','lording','negroid','redoing'};\r\nmax_score_corr = 12;\r\nmax_word_corr = {'inholder'};\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_word = 'novels'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\nwords{2} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','moo','oda','ode','oma','ova','oxo','vex','voe','vox','axed','dame','demo','deva','dome','doom','dove','exam','made','mead','mode','mood','move','moxa','odea','maxed','mooed','moved'};\r\nwords{3} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vav','vex','voe','vox','axed','dame','demo','deva','dome','dove','exam','made','mead','mode','move','moxa','odea','maxed','moved'};\r\nwords{4} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dee','dev','dex','doe','dom','eme','emo','eve','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vee','vex','voe','vox','axed','dame','deem','deme','demo','deva','dome','dove','eave','exam','exed','made','mead','meed','mode','move','moxa','odea','adeem','deave','eaved','edema','evade','maxed','moved','vexed','oedema'};\r\nwords{5} = {'ad','ae','al','am','ax','da','de','do','ed','el','em','ex','la','lo','ma','me','mo','od','oe','om','ox','ado','ale','ave','avo','axe','dal','dam','del','dev','dex','doe','dol','dom','eld','elm','emo','lad','lam','lav','lax','lea','led','lev','lex','lox','mad','mae','max','med','mel','moa','mod','mol','oda','ode','old','ole','oma','ova','vex','voe','vox','alme','aloe','axed','axel','axle','dale','dame','deal','demo','deva','dole','dome','dove','exam','lade','lame','lave','lead','leva','levo','load','loam','lode','love','made','male','mead','meal','meld','mode','mola','mold','mole','move','moxa','odea','olde','olea','oval','vale','veal','vela','veld','vole','amole','axled','dolma','domal','laevo','lamed','laved','loved','loxed','maxed','medal','modal','model','moved','voled','voxel','loamed'};\r\nwords{6} = {'ad','ae','am','as','ax','da','de','do','ed','em','es','ex','ma','me','mo','od','oe','om','os','ox','so','ado','ads','ave','avo','axe','dam','das','dev','dex','doe','dom','dos','eds','emo','ems','mad','mae','mas','max','med','moa','mod','mos','oda','ode','ods','oes','oma','oms','ose','ova','sad','sae','sax','sea','sev','sex','sod','som','sox','vas','vex','voe','vox','ados','aves','avos','axed','axes','dame','dams','demo','deva','devs','does','dome','doms','dosa','dose','dove','emos','exam','made','mads','maes','mead','meds','mesa','moas','mode','mods','move','moxa','odas','odea','odes','omas','oxes','sade','same','save','seam','soda','soma','some','vase','voes','dames','demos','devas','domes','doves','exams','maxed','maxes','meads','modes','moved','moves','moxas','oaves','saved','soave','vadose','vamose','vamosed'};\r\nmax_score_corr = 16;\r\nmax_word_corr = {'vexed'};\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%%\r\nfirst_word = 'zoologist'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aehcmdi'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\nwords{2} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{2} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{4} = {'aced','ache','acid','acme','ahed','ahem','aide','alec','alme','amid','amie','cade','cadi','caid','calm','came','cami','cedi','ceil','chad','chai','cham','chem','chia','chid','clad','clam','dace','dahl','dale','dame','deal','deil','deli','dhal','dial','dice','diel','dime','each','elhi','emic','hade','haed','haem','hail','hale','halm','hame','head','heal','heil','held','helm','hide','hied','hila','iced','idea','idem','idle','ilea','lace','lade','laic','laid','lame','lead','lech','lice','lich','lied','lima','lime','mace','mach','made','maid','mail','male','mead','meal','mech','meld','mica','mice','mild','mile','ached','ailed','aimed','alcid','almeh','amice','amide','camel','chela','chide','chiel','child','chile','chime','clade','claim','clime','decal','demic','email','haled','halid','hemal','hemic','ideal','ileac','laced','laich','lamed','leach','limed','maced','mache','macle','maile','malic','medal','media','medic','melic','miche','milch','calmed','chield','childe','chimed','chimla','haemic','hailed','halide','heliac','hiemal','lamedh','macled','mailed','malice','medial','miched','camelid','claimed','decimal','declaim','medical'};\r\nwords{2} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{6} = {'aced','ache','acid','acme','aged','ahed','ahem','aide','amid','amie','cade','cadi','cage','caid','came','cami','cedi','chad','chai','cham','chem','chia','chid','dace','dame','dice','dime','each','egad','emic','gach','gadi','gaed','game','gied','hade','haed','haem','hame','head','hide','hied','iced','idea','idem','mace','mach','made','mage','magi','maid','mead','mech','mega','mica','mice','ached','aimed','amice','amide','cadge','caged','chide','chime','demic','gamed','gamic','hemic','image','maced','mache','magic','media','medic','miche','midge','chimed','degami','gached','haemic','imaged','miched'};\r\nwords{7} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cedi','chad','chai','cham','chem','chia','chid','dace','dame','dice','dime','each','emic','hade','haed','haem','hame','head','hide','hied','iced','idea','idem','imid','mace','mach','made','maid','mead','mech','mica','mice','midi','ached','aimed','amice','amici','amide','chide','chime','demic','hemic','imide','maced','mache','media','medic','medii','miche','amidic','chimed','haemic','miched'};\r\nwords{8} = {'aced','aces','ache','acid','acme','ahed','ahem','ahis','aide','aids','aims','amid','amie','amis','asci','cade','cadi','cads','caid','came','cami','cams','case','cash','cedi','chad','chai','cham','chem','chia','chid','chis','dace','dahs','dais','dame','dams','dash','desi','dice','dies','dime','dims','disc','dish','each','edhs','emic','hade','haed','haem','haes','hame','hams','head','hems','hide','hied','hies','hims','iced','ices','ichs','idea','idem','ides','mace','mach','macs','made','mads','maes','maid','mash','mead','mech','meds','mesa','mesh','mica','mice','mics','mids','mise','sade','sadi','said','same','scad','scam','seam','semi','shad','sham','shea','shed','shim','sice','side','sidh','sima','ached','aches','acids','acmes','aides','aimed','amice','amide','amids','amies','asdic','ashed','aside','cades','cadis','caids','cames','camis','cased','cedis','chads','chais','chams','chase','chasm','chems','chias','chide','chime','daces','dames','dashi','deash','deism','demic','deshi','dices','dimes','disme','emics','hades','haems','hames','heads','hemic','hides','ideas','maced','maces','mache','machs','maids','meads','mechs','media','medic','mesic','micas','miche','sadhe','saice','shade','shame','shied','sidhe','amices','amides','camise','cashed','chaise','chased','chiasm','chides','chimed','chimes','emdash','haemic','maches','mashed','mashie','medias','medics','miched','miches','sachem','samech','schema','shamed','simcha','chamise','chasmed'};\r\nwords{9} = {'aced','ache','acid','acme','adit','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cate','cedi','chad','chai','cham','chat','chem','chia','chid','chit','cite','dace','dame','date','dice','diet','dime','dita','dite','each','eath','echt','edit','emic','emit','etch','etic','hade','haed','haem','haet','hame','hate','head','heat','hide','hied','iced','idea','idem','itch','item','mace','mach','made','maid','mate','math','mead','meat','mech','meta','meth','mica','mice','mite','tace','tach','tame','team','tech','thae','them','tide','tied','time','ached','acted','admit','aimed','aitch','amice','amide','cadet','cheat','chide','chime','cited','death','demic','demit','dicta','ditch','edict','ethic','hated','hemic','maced','mache','match','mated','media','medic','miche','tache','tamed','teach','theca','timed','chimed','dacite','detach','haemic','itched','miched','hematic','matched'};\r\nmax_score_corr = 19;\r\nmax_word_corr = {'zaideh'};\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(2);\r\nswitch ind\r\n\tcase 1\r\n\t\tfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\n\t\twords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\n\t\twords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\n\t\twords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\n\t\twords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'atheism','hamlets','hematal','thalami','thermal'};\r\n\tcase 2\r\n\t\tfirst_word = 'thinning'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\twords{2} = {'dhole','diner','drone','eloin','enrol','helio','heron','hider','hired','holed','honed','honer','horde','idler','indol','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','rhino','riled','ronde','dehorn','dinero','heroin','hinder','hoiden','holden','holder','holier','hondle','honied','horned','indole','ironed','neroli','roiled','rondel','hordein','inholder'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{8} = {'deign','diner','dinge','dingo','dirge','dogie','doing','drone','eloin','enrol','gelid','genro','geoid','giron','glide','goner','gored','gride','grind','groin','idler','indol','ingle','irone','liger','lined','liner','lingo','loden','lodge','login','loner','longe','nerol','ogled','ogler','oiled','oiler','olden','older','oldie','olein','oriel','redon','reign','renig','reoil','ridge','riled','ronde','dinero','dinger','dingle','doling','dongle','eloign','engild','engird','eringo','gilder','girdle','girned','glider','golden','golder','ignore','indole','ironed','legion','linger','lodger','logier','longed','longer','neroli','reding','regild','region','ridgel','ringed','roiled','rondel','eroding','glenoid','gloried','godlier','groined','ignored','lording','negroid','redoing'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'inholder'};\r\nend\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(2);\r\nswitch ind\r\n\tcase 1\r\n\t\tfirst_word = 'novels'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\n\t\twords{2} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','moo','oda','ode','oma','ova','oxo','vex','voe','vox','axed','dame','demo','deva','dome','doom','dove','exam','made','mead','mode','mood','move','moxa','odea','maxed','mooed','moved'};\r\n\t\twords{3} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vav','vex','voe','vox','axed','dame','demo','deva','dome','dove','exam','made','mead','mode','move','moxa','odea','maxed','moved'};\r\n\t\twords{4} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dee','dev','dex','doe','dom','eme','emo','eve','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vee','vex','voe','vox','axed','dame','deem','deme','demo','deva','dome','dove','eave','exam','exed','made','mead','meed','mode','move','moxa','odea','adeem','deave','eaved','edema','evade','maxed','moved','vexed','oedema'};\r\n\t\twords{5} = {'ad','ae','al','am','ax','da','de','do','ed','el','em','ex','la','lo','ma','me','mo','od','oe','om','ox','ado','ale','ave','avo','axe','dal','dam','del','dev','dex','doe','dol','dom','eld','elm','emo','lad','lam','lav','lax','lea','led','lev','lex','lox','mad','mae','max','med','mel','moa','mod','mol','oda','ode','old','ole','oma','ova','vex','voe','vox','alme','aloe','axed','axel','axle','dale','dame','deal','demo','deva','dole','dome','dove','exam','lade','lame','lave','lead','leva','levo','load','loam','lode','love','made','male','mead','meal','meld','mode','mola','mold','mole','move','moxa','odea','olde','olea','oval','vale','veal','vela','veld','vole','amole','axled','dolma','domal','laevo','lamed','laved','loved','loxed','maxed','medal','modal','model','moved','voled','voxel','loamed'};\r\n\t\twords{6} = {'ad','ae','am','as','ax','da','de','do','ed','em','es','ex','ma','me','mo','od','oe','om','os','ox','so','ado','ads','ave','avo','axe','dam','das','dev','dex','doe','dom','dos','eds','emo','ems','mad','mae','mas','max','med','moa','mod','mos','oda','ode','ods','oes','oma','oms','ose','ova','sad','sae','sax','sea','sev','sex','sod','som','sox','vas','vex','voe','vox','ados','aves','avos','axed','axes','dame','dams','demo','deva','devs','does','dome','doms','dosa','dose','dove','emos','exam','made','mads','maes','mead','meds','mesa','moas','mode','mods','move','moxa','odas','odea','odes','omas','oxes','sade','same','save','seam','soda','soma','some','vase','voes','dames','demos','devas','domes','doves','exams','maxed','maxes','meads','modes','moved','moves','moxas','oaves','saved','soave','vadose','vamose','vamosed'};\r\n\t\tmax_score_corr = 16;\r\n\t\tmax_word_corr = {'vexed'};\r\n\tcase 2\r\n\t\tfirst_word = 'thinning'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\twords{2} = {'dhole','diner','drone','eloin','enrol','helio','heron','hider','hired','holed','honed','honer','horde','idler','indol','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','rhino','riled','ronde','dehorn','dinero','heroin','hinder','hoiden','holden','holder','holier','hondle','honied','horned','indole','ironed','neroli','roiled','rondel','hordein','inholder'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{8} = {'deign','diner','dinge','dingo','dirge','dogie','doing','drone','eloin','enrol','gelid','genro','geoid','giron','glide','goner','gored','gride','grind','groin','idler','indol','ingle','irone','liger','lined','liner','lingo','loden','lodge','login','loner','longe','nerol','ogled','ogler','oiled','oiler','olden','older','oldie','olein','oriel','redon','reign','renig','reoil','ridge','riled','ronde','dinero','dinger','dingle','doling','dongle','eloign','engild','engird','eringo','gilder','girdle','girned','glider','golden','golder','ignore','indole','ironed','legion','linger','lodger','logier','longed','longer','neroli','reding','regild','region','ridgel','ringed','roiled','rondel','eroding','glenoid','gloried','godlier','groined','ignored','lording','negroid','redoing'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'inholder'};\r\nend\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(2);\r\nswitch ind\r\n\tcase 1\r\n\t\tfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\n\t\twords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\n\t\twords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\n\t\twords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\n\t\twords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'atheism','hamlets','hematal','thalami','thermal'};\r\n\tcase 2\r\n\t\tfirst_word = 'thinning'; %the starting word; the new word must be played off of a letter in this word\r\n\t\ttray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n\t\t%all possible words, including each letter of the starting word combined with your tray letters\r\n\t\tclear words\r\n\t\twords{1} = {'diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\n\t\twords{2} = {'dhole','diner','drone','eloin','enrol','helio','heron','hider','hired','holed','honed','honer','horde','idler','indol','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','rhino','riled','ronde','dehorn','dinero','heroin','hinder','hoiden','holden','holder','holier','hondle','honied','horned','indole','ironed','neroli','roiled','rondel','hordein','inholder'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\n\t\twords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\n\t\twords{8} = {'deign','diner','dinge','dingo','dirge','dogie','doing','drone','eloin','enrol','gelid','genro','geoid','giron','glide','goner','gored','gride','grind','groin','idler','indol','ingle','irone','liger','lined','liner','lingo','loden','lodge','login','loner','longe','nerol','ogled','ogler','oiled','oiler','olden','older','oldie','olein','oriel','redon','reign','renig','reoil','ridge','riled','ronde','dinero','dinger','dingle','doling','dongle','eloign','engild','engird','eringo','gilder','girdle','girned','glider','golden','golder','ignore','indole','ironed','legion','linger','lodger','logier','longed','longer','neroli','reding','regild','region','ridgel','ringed','roiled','rondel','eroding','glenoid','gloried','godlier','groined','ignored','lording','negroid','redoing'};\r\n\t\tmax_score_corr = 12;\r\n\t\tmax_word_corr = {'inholder'};\r\nend\r\n[max_score,max_word] = scrabble_scores_12(words,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":223089,"edited_at":"2022-09-11T10:44:01.000Z","deleted_by":null,"deleted_at":null,"solvers_count":24,"test_suite_updated_at":"2022-09-11T10:44:01.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-20T01:12:13.000Z","updated_at":"2026-04-02T08:29:22.000Z","published_at":"2015-03-20T01:12:13.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem builds directly off of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eScrabble Scores - 10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. 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. Write a function to find the highest scoring word, provided any letter from the existing word that you are building off of and the letters on your tray.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRather 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).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 11 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (known letter \u0026amp; multipliers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 13 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3098-scrabble-scores-13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (first word \u0026amp; multipliers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":3052,"title":"Scrabble Scores - 7","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor 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.\r\n\r\nThe 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. \r\n\r\nAs an example, suppose you are given the following board (this is test case 1):\r\n\r\n   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere  \r\n\r\nThe accompanying order array will have a form like the following: \r\n\r\n  order(1) = {[2,2; 5,2]};\r\n  order(2) = {[5,1; 5,5]};\r\n  order(3) = {[1,5; 5,5]};\r\n  order(4) = {[3,5; 3,8]};\r\n  order(5) = {[1,4; 1,6]};\r\n\r\nsignifying 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].\r\n\r\nIf 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.\r\n\r\nFinally, 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.\r\n\r\nWrite a function to calculate and return the total score for each player for the provided Scrabble boards.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 6 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6 Board scoring\u003e. Next problem: 8 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8 Multiplayer multiplier board scoring\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor 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.\u003c/p\u003e\u003cp\u003eThe 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.\u003c/p\u003e\u003cp\u003eAs an example, suppose you are given the following board (this is test case 1):\u003c/p\u003e\u003cpre\u003e   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere  \u003c/pre\u003e\u003cp\u003eThe accompanying order array will have a form like the following:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eorder(1) = {[2,2; 5,2]};\r\norder(2) = {[5,1; 5,5]};\r\norder(3) = {[1,5; 5,5]};\r\norder(4) = {[3,5; 3,8]};\r\norder(5) = {[1,4; 1,6]};\r\n\u003c/pre\u003e\u003cp\u003esignifying 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].\u003c/p\u003e\u003cp\u003eIf 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.\u003c/p\u003e\u003cp\u003eFinally, 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.\u003c/p\u003e\u003cp\u003eWrite a function to calculate and return the total score for each player for the provided Scrabble boards.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 6 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6\"\u003eBoard scoring\u003c/a\u003e. Next problem: 8 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8\"\u003eMultiplayer multiplier board scoring\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_7(board,n_pl,order)\r\n\r\nscore = zeros(1,n_pl);\r\n\r\nend\r\n\r\n","test_suite":"%%\r\nboard = [\r\n\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   ';\r\n];\r\nn_pl = 2;\r\norder = cell(1,5);\r\norder(1) = {[2,2; 5,2]};\r\norder(2) = {[5,1; 5,5]};\r\norder(3) = {[1,5; 5,5]};\r\norder(4) = {[3,5; 3,8]};\r\norder(5) = {[1,4; 1,6]};\r\nscore = [23 14];\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n\r\n%%\r\nboard = [\r\n\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    ';\r\n];\r\nn_pl = 2;\r\norder = cell(1,7);\r\norder(1) = {[1,1; 1,10]};\r\norder(2) = {[1,9; 6,9]};\r\norder(3) = {[1,2; 5,2]};\r\norder(4) = {[5,1; 5,6]};\r\norder(5) = {[5,5; 7,5]};\r\norder(6) = {[3,1; 3,5]};\r\norder(7) = {[7,2; 7,6]};\r\nscore = [29 30];\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' what   y ';\r\n'    h  do ';\r\n'  this  um';\r\n' l  n    a';\r\n' of keen t';\r\n' o   e   l';\r\n' problem a';\r\n'      noob';\r\n];\r\nn_pl = 3;\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,5]};\r\norder(2) = {[1,5; 5,5]};\r\norder(3) = {[3,3; 3,7]};\r\norder(4) = {[5,5; 5,8]};\r\norder(5) = {[5,6; 7,6]};\r\norder(6) = {[7,2; 7,8]};\r\norder(7) = {[4,2; 7,2]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [7,7; 8,7];\r\nm_words(:,:,3) = [7,8; 8,8];\r\norder(8) = {m_words};\r\norder(9) = {[3,10; 8,10]};\r\nclear m_words\r\nm_words(:,:,1) = [1,9; 3,9];\r\nm_words(:,:,2) = [3,9; 3,10];\r\norder(10) = {m_words};\r\norder(11) = {[5,2; 5,3]};\r\norder(12) = {[2,8; 2,9]};\r\nscore = [34 32 33];\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n' e    it l';\r\n' e    v  i';\r\n' please  k';\r\n'      node';\r\n];\r\nn_pl = 2;\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,3]};\r\norder(2) = {[1,3; 4,3]};\r\norder(3) = {[3,3; 3,6]};\r\norder(4) = {[1,6; 3,6]};\r\norder(5) = {[1,6; 1,8]};\r\nm_words(:,:,1) = [4,2; 4,4];\r\nm_words(:,:,2) = [3,4; 4,4];\r\norder(6) = {m_words};\r\norder(7) = {[4,2; 7,2]};\r\norder(8) = {[7,2; 7,7]};\r\norder(9) = {[4,7; 7,7]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [4,7; 8,7];\r\norder(10) = {m_words};\r\norder(11) = {[5,10; 8,10]};\r\norder(12) = {[5,7; 5,8]};\r\nscore = [43 44];\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n\r\n%%\r\nboard = [\r\n\r\n'c    flummoxes zither';\r\n'al    o      e e    e';\r\n'ba  hunting  eerie  b';\r\n'ab  a g   e    o    e';\r\n'lo  n     m g       l';\r\n' r  g      responses ';\r\n'random      n    u u ';\r\n' t  v   c  below p r ';\r\n'convention  r    e f ';\r\n' r  r   n   a   areas';\r\n' y      v c t    i c ';\r\n'   o  philosophy o em';\r\n'travel  n n r    r  e';\r\n'   e    c t         e';\r\n' word   i a    writer';\r\n'   t    n c    o    l';\r\n'p fortnight   rock  y';\r\n'i  n            h    ';\r\n'novelty m concatenate';\r\n'c e  o  a    a  s   g';\r\n'heterogeneousness   g';\r\n];\r\nn_pl = 4;\r\norder = cell(1,41);\r\norder(1) = {[12,7; 12,16]};\r\norder(2) = {[5,13; 13,13]};\r\norder(3) = {[8,9; 17,9]};\r\norder(4) = {[11,11; 17,11]};\r\norder(5) = {[17,3; 17,11]};\r\norder(6) = {[8,12; 8,16]};\r\norder(7) = {[6,12; 6,20]};\r\norder(8) = {[6,18; 13,18]};\r\norder(9) = {[10,17; 10,21]};\r\norder(10) = {[9,1; 9,10]};\r\norder(11) = {[12,4; 19,4]};\r\norder(12) = {[2,2; 11,2]};\r\norder(13) = {[7,1; 7,6]};\r\norder(14) = {[13,1; 13,6]};\r\norder(15) = {[15,2; 15,5]};\r\norder(16) = {[19,1; 19,7]};\r\norder(17) = {[3,5; 10,5]};\r\norder(18) = {[3,5; 3,11]};\r\nm_words(:,:,1) = [1,1; 5,1];\r\nm_words(:,:,2) = [2,1; 2,2];\r\nm_words(:,:,3) = [3,1; 3,2];\r\nm_words(:,:,4) = [4,1; 4,2];\r\nm_words(:,:,5) = [5,1; 5,2];\r\norder(19) = {m_words};\r\norder(20) = {[17,1; 21,1]};\r\norder(21) = {[21,1; 21,17]};\r\norder(22) = {[6,20; 12,20]};\r\nclear m_words\r\nm_words(:,:,1) = [12,21; 17,21];\r\nm_words(:,:,2) = [12,20; 12,21];\r\norder(23) = {m_words};\r\norder(24) = {[15,16; 15,21]};\r\norder(25) = {[3,11; 5,11]};\r\norder(26) = {[17,17; 21,17]};\r\norder(27) = {[17,15; 17,18]};\r\norder(28) = {[19,11; 19,21]};\r\norder(29) = {[19,14; 21,14]};\r\norder(30) = {[1,7; 4,7]};\r\norder(31) = {[1,6; 1,14]};\r\norder(32) = {[19,21; 21,21]};\r\norder(33) = {[19,6; 21,6]};\r\norder(34) = {[1,14; 3,14]};\r\norder(35) = {[3,14; 3,18]};\r\norder(36) = {[1,16; 4,16]};\r\norder(37) = {[1,16; 1,21]};\r\norder(38) = {[1,21; 5,21]};\r\norder(39) = {[19,3; 21,3]};\r\norder(40) = {[19,9; 21,9]};\r\norder(41) = {[15,16; 17,16]};\r\n\r\nscore = [127 92 128 108];\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n\r\n%% anti-cheating test case (random number of players from random board)\r\nind = randi(4);\r\nind2 = randi(3)+1;\r\nswitch ind\r\ncase 1\r\nboard = [\r\n\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   ';\r\n];\r\norder = cell(1,5);\r\norder(1) = {[2,2; 5,2]};\r\norder(2) = {[5,1; 5,5]};\r\norder(3) = {[1,5; 5,5]};\r\norder(4) = {[3,5; 3,8]};\r\norder(5) = {[1,4; 1,6]};\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [23 14];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [15 13 9];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [14 8 9 6];\r\nend\r\ncase 2\r\nboard = [\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    '];\r\norder = cell(1,7);\r\norder(1) = {[1,1; 1,10]};\r\norder(2) = {[1,9; 6,9]};\r\norder(3) = {[1,2; 5,2]};\r\norder(4) = {[5,1; 5,6]};\r\norder(5) = {[5,5; 7,5]};\r\norder(6) = {[3,1; 3,5]};\r\norder(7) = {[7,2; 7,6]};\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [29 30];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [30 13 16];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [16 18 13 12];\r\nend\r\ncase 3\r\nboard = [\r\n\r\n' what   y ';\r\n'    h  do ';\r\n'  this  um';\r\n' l  n    a';\r\n' of keen t';\r\n' o   e   l';\r\n' problem a';\r\n'      noob';\r\n];\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,5]};\r\norder(2) = {[1,5; 5,5]};\r\norder(3) = {[3,3; 3,7]};\r\norder(4) = {[5,5; 5,8]};\r\norder(5) = {[5,6; 7,6]};\r\norder(6) = {[7,2; 7,8]};\r\norder(7) = {[4,2; 7,2]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [7,7; 8,7];\r\nm_words(:,:,3) = [7,8; 8,8];\r\norder(8) = {m_words};\r\norder(9) = {[3,10; 8,10]};\r\nclear m_words\r\nm_words(:,:,1) = [1,9; 3,9];\r\nm_words(:,:,2) = [3,9; 3,10];\r\norder(10) = {m_words};\r\norder(11) = {[5,2; 5,3]};\r\norder(12) = {[2,8; 2,9]};\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [41 58];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [34 32 33];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [23 35 18 23];\r\nend\r\ncase 4\r\nboard = [\r\n\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n' e    it l';\r\n' e    v  i';\r\n' please  k';\r\n'      node';\r\n];\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,3]};\r\norder(2) = {[1,3; 4,3]};\r\norder(3) = {[3,3; 3,6]};\r\norder(4) = {[1,6; 3,6]};\r\norder(5) = {[1,6; 1,8]};\r\nm_words(:,:,1) = [4,2; 4,4];\r\nm_words(:,:,2) = [3,4; 4,4];\r\norder(6) = {m_words};\r\norder(7) = {[4,2; 7,2]};\r\norder(8) = {[7,2; 7,7]};\r\norder(9) = {[4,7; 7,7]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [4,7; 8,7];\r\norder(10) = {m_words};\r\norder(11) = {[5,10; 8,10]};\r\norder(12) = {[5,7; 5,8]};\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [43 44];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [33 29 25];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [19 28 24 16];\r\nend\r\nend\r\nassert(isequal(scrabble_scores_7(board,n_pl,order),score))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":5,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":"2015-03-01T04:17:41.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-02-28T06:51:37.000Z","updated_at":"2026-04-02T20:16:13.000Z","published_at":"2015-03-01T04:17:41.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, suppose you are given the following board (this is test case 1):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   cat  \\n i  p   \\n t  poet\\n c  l   \\nthere]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe accompanying order array will have a form like the following:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[order(1) = {[2,2; 5,2]};\\norder(2) = {[5,1; 5,5]};\\norder(3) = {[1,5; 5,5]};\\norder(4) = {[3,5; 3,8]};\\norder(5) = {[1,4; 1,6]};]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003esignifying 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].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFinally, 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to calculate and return the total score for each player for the provided Scrabble boards.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 6 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3051-scrabble-scores-6\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eBoard scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 8 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3060-scrabble-scores-8\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer multiplier board scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3084,"title":"Scrabble Scores - 11","description":"This problem builds on the previous problem, wherein you were provided a letter of an existing word on the board and from which you played a word to find the highest scoring word. See the previous problem for more details.\r\n\r\nNow, you will be provided a multiplier character array that represents the fifteen possible squares that can be played on, ranging from seven above the existing letter (in which case the existing letter is the last letter in an eight-letter word) to seven below the 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 position. The multipliers are the same as in previous problems:\r\n\r\n * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\r\n\r\nThe center multiplier square will be left blank, since it's already covered by a tile. Write a routine to determine the highest scoring word(s) based on the multiplier squares.\r\n\r\nOnce again, you will be provided a cell array of strings containing all possible words based on the existing letter and the letters on your tray. 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).\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 10 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10 Word score optimization (known letter)\u003e. Next problem: 12 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12 Word score optimization (first word)\u003e.","description_html":"\u003cp\u003eThis problem builds on the previous problem, wherein you were provided a letter of an existing word on the board and from which you played a word to find the highest scoring word. See the previous problem for more details.\u003c/p\u003e\u003cp\u003eNow, you will be provided a multiplier character array that represents the fifteen possible squares that can be played on, ranging from seven above the existing letter (in which case the existing letter is the last letter in an eight-letter word) to seven below the 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 position. The multipliers are the same as in previous problems:\u003c/p\u003e\u003cpre\u003e * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\u003c/pre\u003e\u003cp\u003eThe center multiplier square will be left blank, since it's already covered by a tile. Write a routine to determine the highest scoring word(s) based on the multiplier squares.\u003c/p\u003e\u003cp\u003eOnce again, you will be provided a cell array of strings containing all possible words based on the existing letter and the letters on your tray. 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).\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 10 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\"\u003eWord score optimization (known letter)\u003c/a\u003e. Next problem: 12 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\"\u003eWord score optimization (first word)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score,max_word] = scrabble_scores_11(words,mult,existing_letter)\r\n\r\nscore = 0;\r\nmax_word = {''};\r\n\r\nend","test_suite":"%%\r\nexisting_letter = 's'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nmult = ' T   d   d   T '; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\nmax_score_corr = 39;\r\nmax_word_corr = {'hamlets'};\r\n[max_score,max_word] = scrabble_scores_11(words,mult,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n\r\n%%\r\nind = randi(4);\r\nexisting_letter = 's'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ae','ah','ai','al','am','as','at','eh','el','em','es','et','ha','he','hi','hm','is','it','la','li','ma','me','mi','sh','si','ta','te','ti','ahi','ahs','ail','aim','ais','ait','ale','als','alt','ami','ash','ate','eat','elm','els','ems','est','eta','eth','hae','ham','has','hat','hem','hes','het','hie','him','his','hit','ism','its','lah','lam','las','lat','lea','lei','let','lie','lis','lit','mae','mas','mat','meh','mel','met','mil','mis','sae','sal','sat','sea','sei','sel','set','sha','she','sim','sit','tae','tam','tas','tea','tel','tes','the','tie','til','tis','ahem','ahis','ails','aims','aits','ales','alit','alme','alms','alts','amie','amis','ates','east','eath','eats','elhi','elms','emit','etas','eths','haem','haes','haet','hail','hale','halm','halt','hame','hams','hast','hate','hats','heal','heat','heil','helm','hems','hest','hets','hies','hila','hilt','hims','hist','hits','ilea','isle','item','lahs','lame','lams','lase','lash','last','late','lath','lati','lats','leas','leis','lest','lets','lias','lies','lima','lime','list','lite','lits','maes','mail','male','malt','mash','mast','mate','math','mats','meal','meat','mels','melt','mesa','mesh','meta','meth','mile','mils','milt','mise','mist','mite','sail','sale','salt','same','sate','sati','seal','seam','seat','semi','seta','sham','shea','shim','sial','silt','sima','site','sith','slam','slat','slim','slit','smit','stem','tael','tail','tale','tali','tame','tams','tase','teal','team','teas','tela','tels','thae','them','this','ties','tile','tils','time','aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = ' T   d   d   T '; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 39;\r\n\t\tmax_word_corr = {'hamlets'};\r\n\tcase 2\r\n\t\tmult = 'T  D  d d  D  T'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 32;\r\n\t\tmax_word_corr = {'atheism'};\r\n\tcase 3\r\n\t\tmult = 'Q  t  T T  t  Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 153;\r\n\t\tmax_word_corr = {'halest'};\r\n\tcase 4\r\n\t\tmult = 'Q t T d d T t Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 60;\r\n\t\tmax_word_corr = {'heliast'};\r\nend\r\n[max_score,max_word] = scrabble_scores_11(words,mult,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n\r\n%%\r\nind = randi(4);\r\nexisting_letter = 't'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'de','do','ed','el','en','er','et','id','in','it','li','lo','ne','no','od','oe','oi','on','or','re','te','ti','to','del','den','die','din','dit','doe','dol','don','dor','dot','eld','end','eon','ern','ion','ire','led','lei','let','lid','lie','lin','lit','lot','net','nil','nit','nod','nor','not','ode','oil','old','ole','one','ore','ort','red','rei','ret','rid','rin','rod','roe','rot','ted','tel','ten','tie','til','tin','tod','toe','ton','tor','deil','deli','delt','deni','dent','diel','diet','dine','dino','dint','diol','dire','dirl','dirt','dite','doer','doit','dole','dolt','done','dore','dote','edit','enol','idle','idol','inro','into','ired','iron','lend','leno','lent','lido','lied','lien','lier','line','lino','lint','lion','lire','lite','lode','loid','loin','lone','lord','lore','lorn','loti','nerd','nide','nite','node','nodi','noel','noil','noir','nori','note','olde','orle','redo','rein','rend','reno','rent','ride','riel','rile','rind','riot','rite','rode','roil','role','rote','roti','rotl','tein','tend','tern','tide','tied','tier','tile','tine','tire','tirl','tiro','toed','toil','told','tole','tone','tore','tori','torn','trio','trod','diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = ' T   d   d   T '; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 27;\r\n\t\tmax_word_corr = {'tendril','trindle'};\r\n\tcase 2\r\n\t\tmult = 'T  D  d d  D  T'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 18;\r\n\t\tmax_word_corr = {'retinol','tendril','trindle'};\r\n\tcase 3\r\n\t\tmult = 'Q  t  T T  t  Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 81;\r\n\t\tmax_word_corr = {'retinol'};\r\n\tcase 4\r\n\t\tmult = 'Q t T d d T t Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 90;\r\n\t\tmax_word_corr = {'lentoid'};\r\nend\r\n[max_score,max_word] = scrabble_scores_11(words,mult,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n\r\n%% anti-cheating test case 3\r\nind = randi(4);\r\nexisting_letter = 'n'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = ' T   d   d   T '; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 20;\r\n\t\tmax_word_corr = {'axone'};\r\n\tcase 2\r\n\t\tmult = 'T  D  d d  D  T'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 30;\r\n\t\tmax_word_corr = {'axmen'};\r\n\tcase 3\r\n\t\tmult = 'Q  t  T T  t  Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 108;\r\n\t\tmax_word_corr = {'axone'};\r\n\tcase 4\r\n\t\tmult = 'Q t T d d T t Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 45;\r\n\t\tmax_word_corr = {'axmen'};\r\nend\r\n[max_score,max_word] = scrabble_scores_11(words,mult,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n\r\n\r\n%% anti-cheating test case 4\r\nind = randi(4);\r\nexisting_letter = 'z'; %the word must contain this letter, which is in an already played word\r\ntray_letters = 'aehcmdi'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including the first letter with your tray letters\r\nwords = {'ad','ae','ah','ai','am','da','de','ed','eh','em','ha','he','hi','hm','id','ma','me','mi','za','ace','adz','ahi','aid','aim','ami','cad','cam','chi','dah','dam','die','dim','edh','had','hae','ham','hem','hic','hid','hie','him','ice','ich','mac','mad','mae','med','meh','mic','mid','zed','aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = ' T   d   d   T '; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 24;\r\n\t\tmax_word_corr = {'hazed'};\r\n\tcase 2\r\n\t\tmult = 'T  D  d d  D  T'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 40;\r\n\t\tmax_word_corr = {'zaideh'};\r\n\tcase 3\r\n\t\tmult = 'Q  t  T T  t  Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 162;\r\n\t\tmax_word_corr = {'cazh','hazed'};\r\n\tcase 4\r\n\t\tmult = 'Q t T d d T t Q'; %all possible multiplier squares, from seven above the first letter (meaning your word would end with the first letter) to seven below the first letter (meaning your word would start with the first letter)\r\n\t\tmax_score_corr = 84;\r\n\t\tmax_word_corr = {'zaideh'};\r\nend\r\n[max_score,max_word] = scrabble_scores_11(words,mult,existing_letter);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(max_word,max_word_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":7,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":24,"test_suite_updated_at":"2015-03-17T13:10:14.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-15T00:22:34.000Z","updated_at":"2026-04-02T20:21:03.000Z","published_at":"2015-03-17T01:47:42.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem builds on the previous problem, wherein you were provided a letter of an existing word on the board and from which you played a word to find the highest scoring word. See the previous problem for more details.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNow, you will be provided a multiplier character array that represents the fifteen possible squares that can be played on, ranging from seven above the existing letter (in which case the existing letter is the last letter in an eight-letter word) to seven below the 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 position. The multipliers are the same as in previous problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ * D: double word\\n * T: triple word\\n * Q: quadruple word\\n * d: double letter\\n * t: triple letter\\n * q: quadruple letter]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe center multiplier square will be left blank, since it's already covered by a tile. Write a routine to determine the highest scoring word(s) based on the multiplier squares.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOnce again, you will be provided a cell array of strings containing all possible words based on the existing letter and the letters on your tray. 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).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 10 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3082-scrabble-scores-10\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (known letter)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 12 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (first word)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3098,"title":"Scrabble Scores - 13","description":"This problem integrates components of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11 Scrabble Scores - 11\u003e and \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12 Scrabble Scores - 12\u003e. 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).\r\n\r\nRather 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).\r\n\r\nYou 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:\r\n\r\n * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\r\n\r\nThe center multiplier square will be left blank, since it's already covered by a tile.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 12 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12 Word score optimization (first word)\u003e.","description_html":"\u003cp\u003eThis problem integrates components of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\"\u003eScrabble Scores - 11\u003c/a\u003e and \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\"\u003eScrabble Scores - 12\u003c/a\u003e. 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).\u003c/p\u003e\u003cp\u003eRather 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).\u003c/p\u003e\u003cp\u003eYou 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:\u003c/p\u003e\u003cpre\u003e * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\u003c/pre\u003e\u003cp\u003eThe center multiplier square will be left blank, since it's already covered by a tile.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 12 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\"\u003eWord score optimization (first word)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score,max_word] = scrabble_scores_13(words,mult,first_word)\r\n\r\nscore = 0;\r\nmax_word = {''};\r\n\r\nend","test_suite":"%%\r\nfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\nmult = [' T   d   d   T ';'  d   t t   d  ';' D   t   t   D ';'  d   t t   d  ';' T   d   d   T '];\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nwords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nwords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\nwords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\nwords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nmax_score_corr = 39;\r\nmax_word_corr = {'hamlets'};\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))\r\n\r\n%%\r\nfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\nmult = ['T   d     d   T';'   d       d   ';'  D   d d   D  ';'   d       d   ';'T   d     d   T'];\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nwords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nwords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\nwords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\nwords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nmax_score_corr = 30;\r\nmax_word_corr = {'maltha'};\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))\r\n\r\n%%\r\nfirst_word = 'start'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aethilm'; %your tray letters; informational (not part of the problem)\r\nmult = [' T  d t t d  T ';'D  t d   d t  D';' T d t   t d T ';'D  t d   d t  D';' T  d t t d  T '];\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aisle','alist','almeh','almes','amies','email','emits','haems','haets','hails','hales','halms','halts','hames','haste','hates','heals','heats','heils','heist','helms','hemal','hilts','islet','istle','items','laith','lames','lathe','lathi','laths','leash','least','limas','limes','litas','lites','lithe','maile','mails','maist','males','malts','mates','maths','meals','meats','melts','metal','meths','metis','miles','milts','mites','saith','salmi','satem','selah','setal','shale','shalt','shame','sheal','shiel','slate','slime','smalt','smelt','smile','smite','smith','stale','steal','steam','stela','stile','stime','taels','tails','tales','tames','tamis','teals','teams','telia','tesla','thali','tiles','times','almehs','emails','halest','halite','hamlet','haslet','hiemal','lamest','lathes','lathis','latish','mailes','mashie','mesial','metals','misate','miseat','saithe','saltie','samiel','samite','samlet','sheila','shelta','smalti','stelai','tahsil','thalis','theism','atheism','halites','hamlets','heliast'};\r\nwords{2} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nwords{3} = {'alate','almah','almeh','email','halma','hamal','hemal','laith','lamia','lathe','lathi','lithe','maile','metal','tamal','telia','thali','althea','haemal','halite','hamate','hamlet','hiatal','hiemal','lamiae','malate','maltha','meatal','tamale','hematal','thalami'};\r\nwords{4} = {'aimer','airth','alert','almeh','alter','amrit','ariel','armet','artel','earth','email','haler','harem','hater','heart','hemal','herma','hilar','ihram','irate','ither','laith','lamer','later','lathe','lathi','liter','lithe','litre','maile','mater','merit','metal','miler','mirth','miter','mitre','ramet','ramie','ratel','rathe','realm','relit','remit','retia','taler','tamer','telia','terai','thali','tharm','their','therm','thirl','tiler','timer','trail','trial','armlet','hailer','halier','halite','halter','hamlet','hermai','hermit','hiemal','imaret','lather','lither','mailer','matier','milter','mither','mitral','ramtil','remail','retail','retial','tailer','thairm','thaler','thiram','tramel','lathier','maltier','marlite','thermal'};\r\nwords{5} = {'almeh','atilt','email','hemal','laith','lathe','lathi','latte','lithe','maile','matte','metal','telia','thali','theta','tilth','tithe','title','halite','hamlet','hiemal'};\r\nmax_score_corr = 45;\r\nmax_word_corr = {'hamlets'};\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))\r\n\r\n%%\r\nfirst_word = 'thinning'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'diner','doter','droit','drone','elint','eloin','enrol','ident','idler','indol','inert','inlet','inter','intro','irone','lento','lined','liner','lirot','liter','litre','loden','loner','nerol','niter','nitre','nitro','noted','noter','oiled','oiler','olden','older','oldie','olein','oriel','redon','relit','reoil','riled','ronde','teind','teloi','tenor','tilde','tiled','tiler','tined','tired','toile','toled','tondi','toned','toner','trend','tried','trine','triol','trode','trone','dentil','dinero','dotier','editor','entoil','indole','ironed','linted','linter','loiter','neroli','norite','orient','retold','rident','rioted','rodent','roiled','rondel','tinder','tirled','toiled','toiler','tonier','trined','triode','lentoid','retinol','tendril','trindle'};\r\nwords{2} = {'dhole','diner','drone','eloin','enrol','helio','heron','hider','hired','holed','honed','honer','horde','idler','indol','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','rhino','riled','ronde','dehorn','dinero','heroin','hinder','hoiden','holden','holder','holier','hondle','honied','horned','indole','ironed','neroli','roiled','rondel','hordein','inholder'};\r\nwords{3} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\nwords{4} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{5} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{6} = {'diner','drone','eloin','enrol','idler','indie','indol','indri','iodin','irone','lined','liner','loden','loner','nerol','oiled','oiler','olden','older','oldie','olein','oriel','redon','reoil','riled','ronde','dinero','indole','inlier','iodine','ironed','linier','neroli','oilier','roiled','rondel'};\r\nwords{7} = {'diner','donne','drone','eloin','enrol','idler','indol','inned','inner','irone','lined','linen','liner','loden','loner','nerol','niner','oiled','oiler','olden','older','oldie','olein','oriel','redon','renin','reoil','riled','ronde','ronin','dinero','dinner','endrin','indole','ironed','linden','neroli','online','roiled','rondel','ronnel'};\r\nwords{8} = {'deign','diner','dinge','dingo','dirge','dogie','doing','drone','eloin','enrol','gelid','genro','geoid','giron','glide','goner','gored','gride','grind','groin','idler','indol','ingle','irone','liger','lined','liner','lingo','loden','lodge','login','loner','longe','nerol','ogled','ogler','oiled','oiler','olden','older','oldie','olein','oriel','redon','reign','renig','reoil','ridge','riled','ronde','dinero','dinger','dingle','doling','dongle','eloign','engild','engird','eringo','gilder','girdle','girned','glider','golden','golder','ignore','indole','ironed','legion','linger','lodger','logier','longed','longer','neroli','reding','regild','region','ridgel','ringed','roiled','rondel','eroding','glenoid','gloried','godlier','groined','ignored','lording','negroid','redoing'};\r\nind = randi(3);\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = [' T   d   d   T ';'  d   t t   d  ';' D   t   t   D ';'   D       D   ';'   D       D   ';' D   t   t   D ';'  d   t t   d  ';' T   d   d   T '];\r\n\t\tmax_score_corr = 33;\r\n\t\tmax_word_corr = {'godlier'};\r\n\tcase 2\r\n\t\tmult = ['T   d     d   T';'   d       d   ';'  D   d d   D  ';'   d       d   ';'T   d     d   T';'   d       d   ';'  D   d d   D  ';'   d       d   '];\r\n\t\tmax_score_corr = 16;\r\n\t\tmax_word_corr = {'indole','iodine','ironed','endrin','linden'};\r\n\tcase 3\r\n\t\tmult = ['T   d     d   T';' T  d t t d  T ';'D  t d   d t  D';' T d t   t d T ';'  T   d d   T  ';' T d t   t d T ';'D  t d   d t  D';' T  d t t d  T '];\r\n\t\tmax_score_corr = 45;\r\n\t\tmax_word_corr = {'hordein'};\r\nend\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))\r\n\r\n%%\r\nfirst_word = 'novels'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'ad','ae','am','an','ax','da','de','do','ed','em','en','ex','ma','me','mo','na','ne','no','od','oe','om','on','ox','ado','and','ane','ave','avo','axe','dam','dan','den','dev','dex','doe','dom','don','emo','end','eon','mad','mae','man','max','med','men','moa','mod','mon','nae','nam','nav','nod','nom','oda','ode','oma','one','ova','van','vex','voe','vox','aeon','amen','axed','axon','dame','damn','dean','demo','deva','dome','dona','done','dove','exam','exon','made','mane','mano','mead','mean','mend','meno','moan','mode','move','moxa','name','nave','nema','node','noma','nome','nova','odea','omen','oven','oxen','vane','vena','vend','admen','amend','anode','axmen','axone','daven','demon','devon','doven','maned','maven','maxed','menad','monad','monde','moved','named','nomad','novae','vaned','venom','daemon','moaned'};\r\nwords{2} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','moo','oda','ode','oma','ova','oxo','vex','voe','vox','axed','dame','demo','deva','dome','doom','dove','exam','made','mead','mode','mood','move','moxa','odea','maxed','mooed','moved'};\r\nwords{3} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dev','dex','doe','dom','emo','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vav','vex','voe','vox','axed','dame','demo','deva','dome','dove','exam','made','mead','mode','move','moxa','odea','maxed','moved'};\r\nwords{4} = {'ad','ae','am','ax','da','de','do','ed','em','ex','ma','me','mo','od','oe','om','ox','ado','ave','avo','axe','dam','dee','dev','dex','doe','dom','eme','emo','eve','mad','mae','max','med','moa','mod','oda','ode','oma','ova','vee','vex','voe','vox','axed','dame','deem','deme','demo','deva','dome','dove','eave','exam','exed','made','mead','meed','mode','move','moxa','odea','adeem','deave','eaved','edema','evade','maxed','moved','vexed','oedema'};\r\nwords{5} = {'ad','ae','al','am','ax','da','de','do','ed','el','em','ex','la','lo','ma','me','mo','od','oe','om','ox','ado','ale','ave','avo','axe','dal','dam','del','dev','dex','doe','dol','dom','eld','elm','emo','lad','lam','lav','lax','lea','led','lev','lex','lox','mad','mae','max','med','mel','moa','mod','mol','oda','ode','old','ole','oma','ova','vex','voe','vox','alme','aloe','axed','axel','axle','dale','dame','deal','demo','deva','dole','dome','dove','exam','lade','lame','lave','lead','leva','levo','load','loam','lode','love','made','male','mead','meal','meld','mode','mola','mold','mole','move','moxa','odea','olde','olea','oval','vale','veal','vela','veld','vole','amole','axled','dolma','domal','laevo','lamed','laved','loved','loxed','maxed','medal','modal','model','moved','voled','voxel','loamed'};\r\nwords{6} = {'ad','ae','am','as','ax','da','de','do','ed','em','es','ex','ma','me','mo','od','oe','om','os','ox','so','ado','ads','ave','avo','axe','dam','das','dev','dex','doe','dom','dos','eds','emo','ems','mad','mae','mas','max','med','moa','mod','mos','oda','ode','ods','oes','oma','oms','ose','ova','sad','sae','sax','sea','sev','sex','sod','som','sox','vas','vex','voe','vox','ados','aves','avos','axed','axes','dame','dams','demo','deva','devs','does','dome','doms','dosa','dose','dove','emos','exam','made','mads','maes','mead','meds','mesa','moas','mode','mods','move','moxa','odas','odea','odes','omas','oxes','sade','same','save','seam','soda','soma','some','vase','voes','dames','demos','devas','domes','doves','exams','maxed','maxes','meads','modes','moved','moves','moxas','oaves','saved','soave','vadose','vamose','vamosed'};\r\nind = randi(3);\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = [' T   d   d   T ';'  d   t t   d  ';' D   t   t   D ';'   D       D   ';'   D       D   ';' D   t   t   D '];\r\n\t\tmax_score_corr = 37;\r\n\t\tmax_word_corr = {'vox'};\r\n\tcase 2\r\n\t\tmult = ['T   d     d   T';'  D   d d   D  ';'   d       d   ';'T   d     d   T';'   d       d   ';'  D   d d   D  '];\r\n\t\tmax_score_corr = 25;\r\n\t\tmax_word_corr = {'vox'};\r\n\tcase 3\r\n\t\tmult = [' T  d t t d  T ';'D  t d   d t  D';' T d t   t d T ';'  T   d d   T  ';' T d t   t d T ';'D  t d   d t  D'];\r\n\t\tmax_score_corr = 35;\r\n\t\tmax_word_corr = {'voxel'};\r\nend\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))\r\n\r\n%%\r\nfirst_word = 'zoologist'; %the starting word; the new word must be played off of a letter in this word\r\ntray_letters = 'aehcmdi'; %your tray letters; informational (not part of the problem)\r\n%all possible words, including each letter of the starting word combined with your tray letters\r\nclear words\r\nwords{1} = {'aced','ache','acid','acme','adze','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cazh','cedi','chad','chai','cham','chem','chez','chia','chid','dace','dame','daze','dice','dime','each','emic','hade','haed','haem','hame','haze','head','hide','hied','iced','idea','idem','mace','mach','made','maid','maze','mead','mech','mica','mice','zeda','ached','aimed','amice','amide','azide','chide','chime','demic','hazed','hemic','maced','mache','maize','mazed','media','medic','miche','chimed','haemic','miched','zaideh'};\r\nwords{2} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{3} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{4} = {'aced','ache','acid','acme','ahed','ahem','aide','alec','alme','amid','amie','cade','cadi','caid','calm','came','cami','cedi','ceil','chad','chai','cham','chem','chia','chid','clad','clam','dace','dahl','dale','dame','deal','deil','deli','dhal','dial','dice','diel','dime','each','elhi','emic','hade','haed','haem','hail','hale','halm','hame','head','heal','heil','held','helm','hide','hied','hila','iced','idea','idem','idle','ilea','lace','lade','laic','laid','lame','lead','lech','lice','lich','lied','lima','lime','mace','mach','made','maid','mail','male','mead','meal','mech','meld','mica','mice','mild','mile','ached','ailed','aimed','alcid','almeh','amice','amide','camel','chela','chide','chiel','child','chile','chime','clade','claim','clime','decal','demic','email','haled','halid','hemal','hemic','ideal','ileac','laced','laich','lamed','leach','limed','maced','mache','macle','maile','malic','medal','media','medic','melic','miche','milch','calmed','chield','childe','chimed','chimla','haemic','hailed','halide','heliac','hiemal','lamedh','macled','mailed','malice','medial','miched','camelid','claimed','decimal','declaim','medical'};\r\nwords{5} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','camo','cedi','chad','chai','cham','chao','chem','chia','chid','ciao','coda','code','coed','coma','come','dace','dame','deco','demo','dice','dime','dome','each','echo','emic','hade','haed','haem','hame','head','hide','hied','hoed','homa','home','iced','idea','idem','mace','mach','made','maid','mead','mech','mica','mice','mode','modi','oche','odah','odea','odic','ohed','ohia','ached','aimed','amice','amide','amido','cameo','chemo','chiao','chide','chime','comae','demic','demoi','domic','hemic','homed','homie','maced','mache','macho','mahoe','media','medic','miche','mocha','mochi','ohmic','chimed','codeia','cohead','comade','haemic','hemoid','medico','miched','modica','haemoid'};\r\nwords{6} = {'aced','ache','acid','acme','aged','ahed','ahem','aide','amid','amie','cade','cadi','cage','caid','came','cami','cedi','chad','chai','cham','chem','chia','chid','dace','dame','dice','dime','each','egad','emic','gach','gadi','gaed','game','gied','hade','haed','haem','hame','head','hide','hied','iced','idea','idem','mace','mach','made','mage','magi','maid','mead','mech','mega','mica','mice','ached','aimed','amice','amide','cadge','caged','chide','chime','demic','gamed','gamic','hemic','image','maced','mache','magic','media','medic','miche','midge','chimed','degami','gached','haemic','imaged','miched'};\r\nwords{7} = {'aced','ache','acid','acme','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cedi','chad','chai','cham','chem','chia','chid','dace','dame','dice','dime','each','emic','hade','haed','haem','hame','head','hide','hied','iced','idea','idem','imid','mace','mach','made','maid','mead','mech','mica','mice','midi','ached','aimed','amice','amici','amide','chide','chime','demic','hemic','imide','maced','mache','media','medic','medii','miche','amidic','chimed','haemic','miched'};\r\nwords{8} = {'aced','aces','ache','acid','acme','ahed','ahem','ahis','aide','aids','aims','amid','amie','amis','asci','cade','cadi','cads','caid','came','cami','cams','case','cash','cedi','chad','chai','cham','chem','chia','chid','chis','dace','dahs','dais','dame','dams','dash','desi','dice','dies','dime','dims','disc','dish','each','edhs','emic','hade','haed','haem','haes','hame','hams','head','hems','hide','hied','hies','hims','iced','ices','ichs','idea','idem','ides','mace','mach','macs','made','mads','maes','maid','mash','mead','mech','meds','mesa','mesh','mica','mice','mics','mids','mise','sade','sadi','said','same','scad','scam','seam','semi','shad','sham','shea','shed','shim','sice','side','sidh','sima','ached','aches','acids','acmes','aides','aimed','amice','amide','amids','amies','asdic','ashed','aside','cades','cadis','caids','cames','camis','cased','cedis','chads','chais','chams','chase','chasm','chems','chias','chide','chime','daces','dames','dashi','deash','deism','demic','deshi','dices','dimes','disme','emics','hades','haems','hames','heads','hemic','hides','ideas','maced','maces','mache','machs','maids','meads','mechs','media','medic','mesic','micas','miche','sadhe','saice','shade','shame','shied','sidhe','amices','amides','camise','cashed','chaise','chased','chiasm','chides','chimed','chimes','emdash','haemic','maches','mashed','mashie','medias','medics','miched','miches','sachem','samech','schema','shamed','simcha','chamise','chasmed'};\r\nwords{9} = {'aced','ache','acid','acme','adit','ahed','ahem','aide','amid','amie','cade','cadi','caid','came','cami','cate','cedi','chad','chai','cham','chat','chem','chia','chid','chit','cite','dace','dame','date','dice','diet','dime','dita','dite','each','eath','echt','edit','emic','emit','etch','etic','hade','haed','haem','haet','hame','hate','head','heat','hide','hied','iced','idea','idem','itch','item','mace','mach','made','maid','mate','math','mead','meat','mech','meta','meth','mica','mice','mite','tace','tach','tame','team','tech','thae','them','tide','tied','time','ached','acted','admit','aimed','aitch','amice','amide','cadet','cheat','chide','chime','cited','death','demic','demit','dicta','ditch','edict','ethic','hated','hemic','maced','mache','match','mated','media','medic','miche','tache','tamed','teach','theca','timed','chimed','dacite','detach','haemic','itched','miched','hematic','matched'};\r\nind = randi(3);\r\nswitch ind\r\n\tcase 1\r\n\t\tmult = [' T   d   d   T ';'  d   t t   d  ';' D   t   t   D ';'   D       D   ';' d   T   T   d ';'   D       D   ';' D   t   t   D ';'  d   t t   d  ';' T   d   d   T '];\r\n\t\tmax_score_corr = 117;\r\n\t\tmax_word_corr = {'haemoid'};\r\n\tcase 2\r\n\t\tmult = ['T   d     d   T';'   d       d   ';'  D   d d   D  ';'   d       d   ';'T   d     d   T';'   d       d   ';'  D   d d   D  ';'   d       d   ';'T   d     d   T'];\r\n\t\tmax_score_corr = 28;\r\n\t\tmax_word_corr = {'medico'};\r\n\tcase 3\r\n\t\tmult = ['T   d     d   T';' T  d t t d  T ';'D  t d   d t  D';' T d t   t d T ';'  T   d d   T  ';' T d t   t d T ';'D  t d   d t  D';' T  d t t d  T ';'T   d     d   T'];\r\n\t\tmax_score_corr = 63;\r\n\t\tmax_word_corr = {'decimal'};\r\nend\r\n[max_score,max_word] = scrabble_scores_13(words,mult,first_word);\r\nassert(isequal(max_score,max_score_corr))\r\nassert(isequal(sort(max_word),sort(max_word_corr)))","published":true,"deleted":false,"likes_count":2,"comments_count":6,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":18,"test_suite_updated_at":"2015-03-20T18:02:10.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-20T01:53:26.000Z","updated_at":"2026-04-02T20:22:25.000Z","published_at":"2015-03-20T01:53:26.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem integrates components of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3084-scrabble-scores-11\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eScrabble Scores - 11\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eScrabble Scores - 12\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. 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).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRather 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).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou 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:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ * D: double word\\n * T: triple word\\n * Q: quadruple word\\n * d: double letter\\n * t: triple letter\\n * q: quadruple letter]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe center multiplier square will be left blank, since it's already covered by a tile.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 12 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3097-scrabble-scores-12\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWord score optimization (first word)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3060,"title":"Scrabble Scores - 8","description":"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 \u003chttp://en.wikipedia.org/wiki/Scrabble_letter_distributions#English here\u003e. (Use the English points distribution.)\r\n\r\nFor this problem, you are tasked with scoring a completed multiplayer Scrabble board. You will be provided with a character matrix representing a completed game of Scrabble, the number of players (two to four), an order array denoting the order of word placement, and a multiplier board that corresponds to the character board.\r\n\r\nSee the previous problem for details on the order array (link below). All other details from that problem should be carried over. The multiplier board will be a character matrix of the same size as the board with the following single-letter entries for letter (lowercase) or word (uppercase) multipliers:\r\n\r\n * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\r\n\r\nAs an example, suppose you are given the following board (this is test case 1):\r\n\r\n   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere  \r\n\r\nThe multiplier matrix looks like this:\r\n\r\n  T   d  T\r\n          \r\n  d   D  d\r\n          \r\n  T   d  T\r\n\r\nThe first word to be played, itch, does not cover any multiplier squares, so it is scored as usual. The second word, there, covers the triple-word (T) square in the bottom-left corner in addition to the double-letter (d) square in the bottom center. This means that the last e is doubled (2 points instead of 1) and the entire word score is then tripled.\r\n\r\nThe next word to be played, apple, covers the middle double-word (D) square and the top double-letter (d) square. However, the bottom double-letter (d) square was covered by the previous word and is, therefore, not counted again, per Scrabble rules. So, you'll need to make sure that the entries in the multiplier matrix are cleared out as they are covered with tiles. Each multiplier square counts for all the words scored in a turn (if more than one), but then is covered up for subsequent words.\r\n\r\nWrite a function to calculate and return the total score for each player for the provided Scrabble boards using the accompanying multiplier matrices.\r\n\r\nRelated problems:\r\n\r\nPrevious problem: 7 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7 Multiplayer board scoring\u003e. Next problem: 9 - \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9 Optimal word score\u003e.","description_html":"\u003cp\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided \u003ca href = \"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\"\u003ehere\u003c/a\u003e. (Use the English points distribution.)\u003c/p\u003e\u003cp\u003eFor this problem, you are tasked with scoring a completed multiplayer Scrabble board. You will be provided with a character matrix representing a completed game of Scrabble, the number of players (two to four), an order array denoting the order of word placement, and a multiplier board that corresponds to the character board.\u003c/p\u003e\u003cp\u003eSee the previous problem for details on the order array (link below). All other details from that problem should be carried over. The multiplier board will be a character matrix of the same size as the board with the following single-letter entries for letter (lowercase) or word (uppercase) multipliers:\u003c/p\u003e\u003cpre\u003e * D: double word\r\n * T: triple word\r\n * Q: quadruple word\r\n * d: double letter\r\n * t: triple letter\r\n * q: quadruple letter\u003c/pre\u003e\u003cp\u003eAs an example, suppose you are given the following board (this is test case 1):\u003c/p\u003e\u003cpre\u003e   cat  \r\n i  p   \r\n t  poet\r\n c  l   \r\nthere  \u003c/pre\u003e\u003cp\u003eThe multiplier matrix looks like this:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eT   d  T\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003ed   D  d\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eT   d  T\r\n\u003c/pre\u003e\u003cp\u003eThe first word to be played, itch, does not cover any multiplier squares, so it is scored as usual. The second word, there, covers the triple-word (T) square in the bottom-left corner in addition to the double-letter (d) square in the bottom center. This means that the last e is doubled (2 points instead of 1) and the entire word score is then tripled.\u003c/p\u003e\u003cp\u003eThe next word to be played, apple, covers the middle double-word (D) square and the top double-letter (d) square. However, the bottom double-letter (d) square was covered by the previous word and is, therefore, not counted again, per Scrabble rules. So, you'll need to make sure that the entries in the multiplier matrix are cleared out as they are covered with tiles. Each multiplier square counts for all the words scored in a turn (if more than one), but then is covered up for subsequent words.\u003c/p\u003e\u003cp\u003eWrite a function to calculate and return the total score for each player for the provided Scrabble boards using the accompanying multiplier matrices.\u003c/p\u003e\u003cp\u003eRelated problems:\u003c/p\u003e\u003cp\u003ePrevious problem: 7 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7\"\u003eMultiplayer board scoring\u003c/a\u003e. Next problem: 9 - \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9\"\u003eOptimal word score\u003c/a\u003e.\u003c/p\u003e","function_template":"function [score] = scrabble_scores_8(board,n_pl,order,mult)\r\n\r\nscore = zeros(1,n_pl);\r\n\r\nend\r\n","test_suite":"%%\r\nboard = [\r\n\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   ';\r\n];\r\nn_pl = 2;\r\norder = cell(1,5);\r\norder(1) = {[2,2; 5,2]};\r\norder(2) = {[5,1; 5,5]};\r\norder(3) = {[1,5; 5,5]};\r\norder(4) = {[3,5; 3,8]};\r\norder(5) = {[1,4; 1,6]};\r\nmult = [\r\n\r\n'T   d  T';\r\n'        ';\r\n'd   D  d';\r\n'        ';\r\n'T   d  T';\r\n];\r\nscore = [34 34];\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n\r\n%%\r\nboard = [\r\n\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    ';\r\n];\r\nn_pl = 2;\r\norder = cell(1,7);\r\norder(1) = {[1,1; 1,10]};\r\norder(2) = {[1,9; 6,9]};\r\norder(3) = {[1,2; 5,2]};\r\norder(4) = {[5,1; 5,6]};\r\norder(5) = {[5,5; 7,5]};\r\norder(6) = {[3,1; 3,5]};\r\norder(7) = {[7,2; 7,6]};\r\nmult = [\r\n\r\n'T  t  t  T';\r\n'          ';\r\n'D  d  d  D';\r\n'          ';\r\n'D  d  d  D';\r\n'          ';\r\n'T  t  t  T';\r\n];\r\nscore = [189 54];\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' what   y ';\r\n'    h  do ';\r\n'  this  um';\r\n' l  n    a';\r\n' of keen t';\r\n' o   e   l';\r\n' problem a';\r\n'      noob';\r\n];\r\nn_pl = 3;\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,5]};\r\norder(2) = {[1,5; 5,5]};\r\norder(3) = {[3,3; 3,7]};\r\norder(4) = {[5,5; 5,8]};\r\norder(5) = {[5,6; 7,6]};\r\norder(6) = {[7,2; 7,8]};\r\norder(7) = {[4,2; 7,2]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [7,7; 8,7];\r\nm_words(:,:,3) = [7,8; 8,8];\r\norder(8) = {m_words};\r\norder(9) = {[3,10; 8,10]};\r\nclear m_words\r\nm_words(:,:,1) = [1,9; 3,9];\r\nm_words(:,:,2) = [3,9; 3,10];\r\norder(10) = {m_words};\r\norder(11) = {[5,2; 5,3]};\r\norder(12) = {[2,8; 2,9]};\r\nmult = [\r\n\r\n'T    t   T';\r\n' d      d ';\r\n'  d    d  ';\r\n'   D     t';\r\n't     D   ';\r\n'  d    d  ';\r\n' d      d ';\r\n'T   t    T';\r\n];\r\nscore = [43 44 39];\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n\r\n%%\r\nboard = [\r\n\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n' e    it l';\r\n' e    v  i';\r\n' please  k';\r\n'      node';\r\n];\r\nn_pl = 2;\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,3]};\r\norder(2) = {[1,3; 4,3]};\r\norder(3) = {[3,3; 3,6]};\r\norder(4) = {[1,6; 3,6]};\r\norder(5) = {[1,6; 1,8]};\r\nm_words(:,:,1) = [4,2; 4,4];\r\nm_words(:,:,2) = [3,4; 4,4];\r\norder(6) = {m_words};\r\norder(7) = {[4,2; 7,2]};\r\norder(8) = {[7,2; 7,7]};\r\norder(9) = {[4,7; 7,7]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [4,7; 8,7];\r\norder(10) = {m_words};\r\norder(11) = {[5,10; 8,10]};\r\norder(12) = {[5,7; 5,8]};\r\nmult = [\r\n\r\n' T   T  T ';\r\n'   d     d';\r\n'  D   D   ';\r\n' D t  d   ';\r\n'         d';\r\n'   d  t   ';\r\n' d  D   D ';\r\n'  T   T  T';\r\n];\r\nscore = [67 140];\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n\r\n%\r\nboard = [\r\n\r\n'c    flummoxes zither';\r\n'al    o      e e    e';\r\n'ba  hunting  eerie  b';\r\n'ab  a g   e    o    e';\r\n'lo  n     m g       l';\r\n' r  g      responses ';\r\n'random      n    u u ';\r\n' t  v   c  below p r ';\r\n'convention  r    e f ';\r\n' r  r   n   a   areas';\r\n' y      v c t    i c ';\r\n'   o  philosophy o em';\r\n'travel  n n r    r  e';\r\n'   e    c t         e';\r\n' word   i a    writer';\r\n'   t    n c    o    l';\r\n'p fortnight   rock  y';\r\n'i  n            h    ';\r\n'novelty m concatenate';\r\n'c e  o  a    a  s   g';\r\n'heterogeneousness   g';\r\n];\r\nn_pl = 4;\r\norder = cell(1,41);\r\norder(1) = {[12,7; 12,16]};\r\norder(2) = {[5,13; 13,13]};\r\norder(3) = {[8,9; 17,9]};\r\norder(4) = {[11,11; 17,11]};\r\norder(5) = {[17,3; 17,11]};\r\norder(6) = {[8,12; 8,16]};\r\norder(7) = {[6,12; 6,20]};\r\norder(8) = {[6,18; 13,18]};\r\norder(9) = {[10,17; 10,21]};\r\norder(10) = {[9,1; 9,10]};\r\norder(11) = {[12,4; 19,4]};\r\norder(12) = {[2,2; 11,2]};\r\norder(13) = {[7,1; 7,6]};\r\norder(14) = {[13,1; 13,6]};\r\norder(15) = {[15,2; 15,5]};\r\norder(16) = {[19,1; 19,7]};\r\norder(17) = {[3,5; 10,5]};\r\norder(18) = {[3,5; 3,11]};\r\nm_words(:,:,1) = [1,1; 5,1];\r\nm_words(:,:,2) = [2,1; 2,2];\r\nm_words(:,:,3) = [3,1; 3,2];\r\nm_words(:,:,4) = [4,1; 4,2];\r\nm_words(:,:,5) = [5,1; 5,2];\r\norder(19) = {m_words};\r\norder(20) = {[17,1; 21,1]};\r\norder(21) = {[21,1; 21,17]};\r\norder(22) = {[6,20; 12,20]};\r\nclear m_words\r\nm_words(:,:,1) = [12,21; 17,21];\r\nm_words(:,:,2) = [12,20; 12,21];\r\norder(23) = {m_words};\r\norder(24) = {[15,16; 15,21]};\r\norder(25) = {[3,11; 5,11]};\r\norder(26) = {[17,17; 21,17]};\r\norder(27) = {[17,15; 17,18]};\r\norder(28) = {[19,11; 19,21]};\r\norder(29) = {[19,14; 21,14]};\r\norder(30) = {[1,7; 4,7]};\r\norder(31) = {[1,6; 1,14]};\r\norder(32) = {[19,21; 21,21]};\r\norder(33) = {[19,6; 21,6]};\r\norder(34) = {[1,14; 3,14]};\r\norder(35) = {[3,14; 3,18]};\r\norder(36) = {[1,16; 4,16]};\r\norder(37) = {[1,16; 1,21]};\r\norder(38) = {[1,21; 5,21]};\r\norder(39) = {[19,3; 21,3]};\r\norder(40) = {[19,9; 21,9]};\r\norder(41) = {[15,16; 17,16]};\r\nmult = [\r\n\r\n'Q  d   T  d  T   d  Q';\r\n' D  t   D   D   t  D ';\r\n'  D  q   D D   q  D  ';\r\n'd  T  d   T   d  T  d';\r\n' t  D   t   t   D  t ';\r\n'  q  D   d d   D  q  ';\r\n'   d  D   d   D  d   ';\r\n'T      D     D      T';\r\n' D  t   t   t   t  D ';\r\n'  D  d   d d   d  D  ';\r\n'd   T d   D   d  T  d';\r\n'  D  d   d d   d  D  ';\r\n' D  t   t   t   t  D ';\r\n'T      D     D      T';\r\n'   d  D   d   D  d   ';\r\n'  q  D   d d   D  q  ';\r\n' t  D   t   t   D  t ';\r\n'd  T  d   T   d  T  d';\r\n'  D  q   D D   q  D  ';\r\n' D  t   D   D   t  D ';\r\n'Q  d   T  d  T   d  Q';\r\n];\r\nscore = [433 188 430 300];\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n\r\n%% anti-cheating test case (random number of players from random board)\r\nind = randi(4);\r\nind2 = randi(3)+1;\r\nswitch ind\r\ncase 1\r\nboard = [\r\n\r\n'   cat  ';\r\n' i  p   ';\r\n' t  poet';\r\n' c  l   ';\r\n'there   ';\r\n];\r\norder = cell(1,5);\r\norder(1) = {[2,2; 5,2]};\r\norder(2) = {[5,1; 5,5]};\r\norder(3) = {[1,5; 5,5]};\r\norder(4) = {[3,5; 3,8]};\r\norder(5) = {[1,4; 1,6]};\r\nmult = [\r\n\r\n'T   d  T';\r\n'        ';\r\n'd   D  d';\r\n'        ';\r\n'T   d  T';\r\n];\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [34 34];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [16 32 20];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [14 27 20 7];\r\nend\r\ncase 2\r\nboard = [\r\n'stratagems';\r\n' h      a ';\r\n'hello   t ';\r\n' r      l ';\r\n'fellow  a ';\r\n'    a   b ';\r\n' users    '];\r\norder = cell(1,7);\r\norder(1) = {[1,1; 1,10]};\r\norder(2) = {[1,9; 6,9]};\r\norder(3) = {[1,2; 5,2]};\r\norder(4) = {[5,1; 5,6]};\r\norder(5) = {[5,5; 7,5]};\r\norder(6) = {[3,1; 3,5]};\r\norder(7) = {[7,2; 7,6]};\r\nmult = [\r\n\r\n'T  t  t  T';\r\n'          ';\r\n'D  d  d  D';\r\n'          ';\r\n'D  d  d  D';\r\n'          ';\r\n'T  t  t  T';\r\n];\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [189 54];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [204 13 26];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [174 28 15 26];\r\nend\r\ncase 3\r\nboard = [\r\n\r\n' what   y ';\r\n'    h  do ';\r\n'  this  um';\r\n' l  n    a';\r\n' of keen t';\r\n' o   e   l';\r\n' problem a';\r\n'      noob';\r\n];\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,5]};\r\norder(2) = {[1,5; 5,5]};\r\norder(3) = {[3,3; 3,7]};\r\norder(4) = {[5,5; 5,8]};\r\norder(5) = {[5,6; 7,6]};\r\norder(6) = {[7,2; 7,8]};\r\norder(7) = {[4,2; 7,2]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [7,7; 8,7];\r\nm_words(:,:,3) = [7,8; 8,8];\r\norder(8) = {m_words};\r\norder(9) = {[3,10; 8,10]};\r\nclear m_words\r\nm_words(:,:,1) = [1,9; 3,9];\r\nm_words(:,:,2) = [3,9; 3,10];\r\norder(10) = {m_words};\r\norder(11) = {[5,2; 5,3]};\r\norder(12) = {[2,8; 2,9]};\r\nmult = [\r\n\r\n'T    t   T';\r\n' d      d ';\r\n'  d    d  ';\r\n'   D     t';\r\n't     D   ';\r\n'  d    d  ';\r\n' d      d ';\r\n'T   t    T';\r\n];\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [44 82];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [43 44 39];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [25 39 19 43];\r\nend\r\ncase 4\r\nboard = [\r\n\r\n' if  you  ';\r\n'  i  u    ';\r\n'  like    ';\r\n' met  g   ';\r\n' e    it l';\r\n' e    v  i';\r\n' please  k';\r\n'      node';\r\n];\r\norder = cell(1,12);\r\norder(1) = {[1,2; 1,3]};\r\norder(2) = {[1,3; 4,3]};\r\norder(3) = {[3,3; 3,6]};\r\norder(4) = {[1,6; 3,6]};\r\norder(5) = {[1,6; 1,8]};\r\nm_words(:,:,1) = [4,2; 4,4];\r\nm_words(:,:,2) = [3,4; 4,4];\r\norder(6) = {m_words};\r\norder(7) = {[4,2; 7,2]};\r\norder(8) = {[7,2; 7,7]};\r\norder(9) = {[4,7; 7,7]};\r\nm_words(:,:,1) = [8,7; 8,10];\r\nm_words(:,:,2) = [4,7; 8,7];\r\norder(10) = {m_words};\r\norder(11) = {[5,10; 8,10]};\r\norder(12) = {[5,7; 5,8]};\r\nmult = [\r\n\r\n' T   T  T ';\r\n'   d     d';\r\n'  D   D   ';\r\n' D t  d   ';\r\n'         d';\r\n'   d  t   ';\r\n' d  D   D ';\r\n'  T   T  T';\r\n];\r\nswitch ind2\r\n\tcase 2\r\n\t\tn_pl = 2;\r\n\t\tscore = [67 140];\r\n\tcase 3\r\n\t\tn_pl = 3;\r\n\t\tscore = [116 45 46];\r\n\tcase 4\r\n\t\tn_pl = 4;\r\n\t\tscore = [39 104 28 36];\r\nend\r\nend\r\nassert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":23,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":40,"created_at":"2015-03-03T05:04:53.000Z","updated_at":"2026-04-02T20:17:44.000Z","published_at":"2015-03-03T05:04:53.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is part of a set of problems that successively develop a more sophisticated Scrabble scoring routine. The point distribution for scoring is provided\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Scrabble_letter_distributions#English\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (Use the English points distribution.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you are tasked with scoring a completed multiplayer Scrabble board. You will be provided with a character matrix representing a completed game of Scrabble, the number of players (two to four), an order array denoting the order of word placement, and a multiplier board that corresponds to the character board.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee the previous problem for details on the order array (link below). All other details from that problem should be carried over. The multiplier board will be a character matrix of the same size as the board with the following single-letter entries for letter (lowercase) or word (uppercase) multipliers:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ * D: double word\\n * T: triple word\\n * Q: quadruple word\\n * d: double letter\\n * t: triple letter\\n * q: quadruple letter]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, suppose you are given the following board (this is test case 1):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   cat  \\n i  p   \\n t  poet\\n c  l   \\nthere]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe multiplier matrix looks like this:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[T   d  T\\n\\nd   D  d\\n\\nT   d  T]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe first word to be played, itch, does not cover any multiplier squares, so it is scored as usual. The second word, there, covers the triple-word (T) square in the bottom-left corner in addition to the double-letter (d) square in the bottom center. This means that the last e is doubled (2 points instead of 1) and the entire word score is then tripled.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe next word to be played, apple, covers the middle double-word (D) square and the top double-letter (d) square. However, the bottom double-letter (d) square was covered by the previous word and is, therefore, not counted again, per Scrabble rules. So, you'll need to make sure that the entries in the multiplier matrix are cleared out as they are covered with tiles. Each multiplier square counts for all the words scored in a turn (if more than one), but then is covered up for subsequent words.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to calculate and return the total score for each player for the provided Scrabble boards using the accompanying multiplier matrices.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRelated problems:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: 7 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3052-scrabble-scores-7\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMultiplayer board scoring\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 9 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3062-scrabble-scores-9\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOptimal word score\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"word\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"word\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"word\"","","\"","word","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fac4ae3aa00\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fac4ae3a8c0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fac4ae38e80\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fac4ae3adc0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fac4ae3ad20\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fac4ae3abe0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fac4ae3ab40\u003e":"tag:\"word\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fac4ae3ab40\u003e":"tag:\"word\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"word\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"word\"","","\"","word","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fac4ae3aa00\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fac4ae3a8c0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fac4ae38e80\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fac4ae3adc0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fac4ae3ad20\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fac4ae3abe0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fac4ae3ab40\u003e":"tag:\"word\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fac4ae3ab40\u003e":"tag:\"word\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":3047,"difficulty_rating":"easy-medium"},{"id":3018,"difficulty_rating":"easy-medium"},{"id":3019,"difficulty_rating":"easy-medium"},{"id":3051,"difficulty_rating":"easy-medium"},{"id":3082,"difficulty_rating":"easy-medium"},{"id":3050,"difficulty_rating":"easy-medium"},{"id":3062,"difficulty_rating":"easy-medium"},{"id":44816,"difficulty_rating":"easy-medium"},{"id":3049,"difficulty_rating":"easy-medium"},{"id":3048,"difficulty_rating":"easy-medium"},{"id":3081,"difficulty_rating":"easy-medium"},{"id":53960,"difficulty_rating":"medium"},{"id":44815,"difficulty_rating":"medium"},{"id":3097,"difficulty_rating":"medium"},{"id":3052,"difficulty_rating":"medium"},{"id":3084,"difficulty_rating":"medium"},{"id":3098,"difficulty_rating":"medium-hard"},{"id":3060,"difficulty_rating":"medium-hard"}]}}