{"group":{"group":{"id":40,"name":"Word Puzzles","lockable":false,"created_at":"2018-04-10T12:45:11.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Challenge your MATLAB skills by solving these word puzzles.","is_default":false,"created_by":26769,"badge_id":55,"featured":false,"trending":false,"solution_count_in_trending_period":5,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":417,"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":"{\"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\u003eChallenge your MATLAB skills by solving these word puzzles.\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\"}]}","description_html":"\u003cdiv style = \"text-align: start; line-height: normal; 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=\"display: block; min-width: 0px; padding-top: 0px; perspective-origin: 289.5px 10.5px; transform-origin: 289.5px 10.5px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; perspective-origin: 266.5px 10.5px; transform-origin: 266.5px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eChallenge your MATLAB skills by solving these word puzzles.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2019-05-08T20:14:39.000Z"},"current_player":null},"problems":[{"id":44351,"title":"Code breaker, Part I:  Operation Phoenix","description":"You have been tasked with decoding a set of coded messages that have been intercepted.  \r\n\r\nBased on previous intelligence that has been gathered, you can be confident that the messages were encoded using a simple \u003chttps://en.wikipedia.org/wiki/Caesar_cipher Caesar cipher\u003e (a type of \u003chttps://en.wikipedia.org/wiki/Substitution_cipher substitution cipher\u003e), an example of which is the \u003chttps://en.wikipedia.org/wiki/ROT13 ROT13 cipher\u003e (discussed in \u003chttps://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher Cody Challenge Problem 78\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between messages (also, here you need to decode, not encode).  \r\n\r\nYou can also assume that the original message will relate to an activity that is referred to by those involved as \"Operation Phoenix\". Therefore the phrase \"Operation Phoenix\" (with that capitalisation) would have appeared at least once in the original message.  \r\n\r\nYour task is to crack the codes and report back in a \u003chttp://au.mathworks.com/help/matlab/ref/struct.html structure array\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e];  (2)  the decoded message [as \u003chttp://au.mathworks.com/help/matlab/ref/char.html character array\u003e].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".  \r\n\r\nEXAMPLE\r\n\r\nSuppose the original message was _\"Cancel Operation Phoenix immediately \u0026 escape.\"_ and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the encoded message would be:  _\"Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.\"_\r\n\r\nThe correct answer would comprise:  \r\n\r\n  s.shift = uint8(1)  \r\n  s.message = 'Cancel Operation Phoenix immediately \u0026 escape.'\r\n\r\n|Note: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable and doesn't generate excessive text output). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand.|  \r\n\r\nTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\r\n\r\n----------\r\n\r\nNext problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44356 Operation Orthos\u003e.\r\n\r\n----------\r\n\r\nStatistics on solutions submitted as at 15 October 2017:\r\n\r\n* *Fastest wall time to decode 5000 messages = 93 milliseconds* , for \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303 Solution 1279303\u003e, with a size-based score of 40. \r\n* *Smallest size-based score = 38* , for \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1278780 Solution 1278780\u003e, for which wall time to decode 5000 messages = 515 milliseconds.  \r\n* Best combined score = 49, for \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303 Solution 1279303\u003e. ","description_html":"\u003cp\u003eYou have been tasked with decoding a set of coded messages that have been intercepted.\u003c/p\u003e\u003cp\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were encoded using a simple \u003ca href = \"https://en.wikipedia.org/wiki/Caesar_cipher\"\u003eCaesar cipher\u003c/a\u003e (a type of \u003ca href = \"https://en.wikipedia.org/wiki/Substitution_cipher\"\u003esubstitution cipher\u003c/a\u003e), an example of which is the \u003ca href = \"https://en.wikipedia.org/wiki/ROT13\"\u003eROT13 cipher\u003c/a\u003e (discussed in \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\"\u003eCody Challenge Problem 78\u003c/a\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between messages (also, here you need to decode, not encode).\u003c/p\u003e\u003cp\u003eYou can also assume that the original message will relate to an activity that is referred to by those involved as \"Operation Phoenix\". Therefore the phrase \"Operation Phoenix\" (with that capitalisation) would have appeared at least once in the original message.\u003c/p\u003e\u003cp\u003eYour task is to crack the codes and report back in a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/struct.html\"\u003estructure array\u003c/a\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e];  (2)  the decoded message [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/char.html\"\u003echaracter array\u003c/a\u003e].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".\u003c/p\u003e\u003cp\u003eEXAMPLE\u003c/p\u003e\u003cp\u003eSuppose the original message was \u003ci\u003e\"Cancel Operation Phoenix immediately \u0026 escape.\"\u003c/i\u003e and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the encoded message would be:  \u003ci\u003e\"Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.\"\u003c/i\u003e\u003c/p\u003e\u003cp\u003eThe correct answer would comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(1)  \r\ns.message = 'Cancel Operation Phoenix immediately \u0026 escape.'\r\n\u003c/pre\u003e\u003cp\u003e\u003ctt\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable and doesn't generate excessive text output). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand.\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003eNext problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44356\"\u003eOperation Orthos\u003c/a\u003e.\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003eStatistics on solutions submitted as at 15 October 2017:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003cb\u003eFastest wall time to decode 5000 messages = 93 milliseconds\u003c/b\u003e , for \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\"\u003eSolution 1279303\u003c/a\u003e, with a size-based score of 40.\u003c/li\u003e\u003cli\u003e\u003cb\u003eSmallest size-based score = 38\u003c/b\u003e , for \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1278780\"\u003eSolution 1278780\u003c/a\u003e, for which wall time to decode 5000 messages = 515 milliseconds.\u003c/li\u003e\u003cli\u003eBest combined score = 49, for \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\"\u003eSolution 1279303\u003c/a\u003e.\u003c/li\u003e\u003c/ul\u003e","function_template":"function s = decode(x)\r\n  s = x;\r\nend","test_suite":"%% NOTE:  \r\n% This test suite can be updated if inappropriate 'hacks' \r\n% are discovered in any submitted solutions, \r\n% so your score/size may therefore change over time.  \r\n\r\n\r\n%% Test 1\r\nx = 'Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.';\r\ns_correct.shift = 1;\r\ns_correct.message = 'Cancel Operation Phoenix immediately \u0026 escape.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Test 2\r\nx = 'Vwlyhapvu Wovlupe ilnpuz Ablzkhf!  Vwlyhapvu Wovlupe pz vby avw wypvypaf.';\r\ns_correct.shift = 7;\r\ns_correct.message = 'Operation Phoenix begins Tuesday!  Operation Phoenix is our top priority.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Test 3\r\nx = 'Eatpht cdit iwpi iwt ephhldgs wph qttc rwpcvts ugdb \"Fxeudyn\" id \"Dvcsbwl\".  Diwtglxht Detgpixdc Ewdtcxm xh egdrttsxcv prrdgsxcv id eapc.';\r\ns_correct.shift = 15;\r\ns_correct.message = 'Please note that the password has been changed from \"Qipfojy\" to \"Ogndmhw\".  Otherwise Operation Phoenix is proceeding according to plan.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Test 4\r\nx = 'Mncpyrgml Nfmclgv qryprcb rfpcc bywq yem.  Yjj ncpqmllcj ypc rm pckygl ml bsrw slrgj Mncpyrgml Nfmclgv gq amknjcrcb.';\r\ns_correct.shift = 24;\r\ns_correct.message = 'Operation Phoenix started three days ago.  All personnel are to remain on duty until Operation Phoenix is completed.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Rescoring \r\n% Acknowledgements \r\n% Portions of this timing test code were inspired by:\r\n% (1) Problem 937. \"Rubik's Mini Cube: Solve Randomized Cube in 11 Moves or Less; Score is by Time (msec)\" by Richard Zapor.\r\n% (2) Problem 2733. \"Evil Number\" by Jan Orwat.\r\n% (3) Feedback in comments from Peng Liu.\r\n% (4) Problem Problem 1237. \"It's race time! Write a faster function than the test suite call of unique().\" by Jeremy.\r\n\r\n% Note:  The Time Trial section does not check accuracy; that is done above.\r\n\r\n% Initialise\r\nx = 'Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.';\r\ncutoffTimeBig = 1000; % Maximum allowable walltime (in milliseconds) to run function in a loop with qBig iterations.\r\n\r\nfor dummy = 1 : 20,  disp(' . ');  end;\r\n\r\n% Run once, untimed?\r\nincludeOverheads = false;\r\nif includeOverheads, \r\n    solution = decode( x );\r\nend;\r\n\r\n% *** PRELIMINARY TIMING ***\r\n% In case the submitted function has a lot of text output, \r\n% get an estimate based on just a few iterations\r\n% Initialise\r\nqSmall = 50;\r\nqBig = 5000;\r\nt0 = clock;\r\n\r\n% Loop\r\nfor i = 1 : qSmall\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0) * 1000;\r\ndisp('     -----=====-----     ')\r\nfprintf('Your wall time to decode %u messages = %i msec.\\n\\r', qSmall, floor(dt))\r\nfprintf('Your APPROXIMATE wall time to decode %u messages would be ~ %i msec.\\n\\r', qBig, ceil(dt * qBig / qSmall))\r\ndisp('     -----=====-----     ')\r\nfor dummy = 1 : 20,  disp(' . ');  end;\r\n\r\n% *** 'OFFICIAL' TIMING ***\r\n% Re-initialise timer\r\nt0 = clock;\r\nt0_cpu = cputime;\r\n\r\n% Loop\r\nfor i = 1 : qBig\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\nfor dummy = 1 : 20,  disp(' . ');  end;\r\ndisp('     -----=====|||||=====-----     ')\r\ndt = etime(clock, t0) * 1000;\r\nfprintf('Your wall time to decode %u messages = %i msec.\\n\\r', qBig, floor(dt))\r\n\r\ndt_cpu = (cputime - t0_cpu) * 1000;\r\nfprintf(' ( Your CPU time for this = %i msec. ) \\n\\r', floor(dt_cpu))\r\n\r\nfDecode = @()   decode(x);\r\ndt_timeit = timeit( fDecode ) * 1000;\r\nfprintf(' [ Your ''timeit'' time to decode %u messages = %i msec. ] \\n\\r', qBig, ceil(dt_timeit * qBig))\r\n\r\n% Display a size-based score.\r\nall_nodes = mtree('decode.m', '-file');        % This is the default in Cody.\r\nstr_nodes = mtfind(all_nodes, 'Kind', 'STRING');\r\neq_nodes = mtfind(all_nodes, 'Kind', 'EQUALS');\r\nprint_nodes = mtfind(all_nodes, 'Kind', 'PRINT');\r\nexpr_nodes = mtfind(all_nodes, 'Kind', 'EXPR');\r\n\r\nsize_score = count(all_nodes) ...\r\n +sum(str_nodes.nodesize-1) ...\r\n +2*(count(expr_nodes) ...\r\n +count(print_nodes) ...\r\n -count(eq_nodes));\r\n\r\nfprintf('Your size-based score = %i.\\n\\r', size_score)\r\n\r\n% Report revised performance score.\r\ncombinedScore = size_score  +  min( 200, floor(dt*(500/qBig)) );\r\nfprintf('Your combined score = %i.\\n\\r', combinedScore)\r\ndisp('     -----=====|||||=====-----     ')\r\n\r\n% Now disallow any candidate solutions that are TOO SLOW!\r\nif dt \u003e cutoffTimeBig, \r\n    fprintf('Sorry, your submission is TOO SLOW. It must be able to finish within %u milliseconds.\\n\\r', cutoffTimeBig)\r\nend;\r\n\r\nassert( dt \u003c= cutoffTimeBig, 'Exceeded time limit specified in Test Suite.' )","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":45,"test_suite_updated_at":"2017-10-15T10:19:08.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2017-09-29T09:20:59.000Z","updated_at":"2026-04-02T08:27:57.000Z","published_at":"2017-09-29T13:45:26.000Z","restored_at":"2017-10-04T19:25:07.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003eYou have been tasked with decoding a set of coded messages that have been intercepted.\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\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were encoded using a simple\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://en.wikipedia.org/wiki/Caesar_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCaesar cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (a type 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://en.wikipedia.org/wiki/Substitution_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esubstitution cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e), an example of which is the\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://en.wikipedia.org/wiki/ROT13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eROT13 cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (discussed in\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/78-implement-a-rot13-cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Challenge Problem 78\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e). As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026amp; numbers) are unchanged. Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between messages (also, here you need to decode, not encode).\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 can also assume that the original message will relate to an activity that is referred to by those involved as \\\"Operation Phoenix\\\". Therefore the phrase \\\"Operation Phoenix\\\" (with that capitalisation) would have appeared at least once in the original message.\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\u003eYour task is to crack the codes and report back in a\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://au.mathworks.com/help/matlab/ref/struct.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estructure array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e: (1) the shifting parameter that had been used in the encoding [as\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://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e]; (2) the decoded message [as\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://au.mathworks.com/help/matlab/ref/char.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003echaracter array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e]. The name of the structure array shall be \\\"s\\\", with respective fields \\\"shift\\\" and \\\"message\\\".\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\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the original message was\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Cancel Operation Phoenix immediately \u0026amp; escape.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and a (right-shifting) ROT1 cipher had been applied. In that case A→B, B→C, ..., Y→Z, and Z→A; similarly, a→b, b→c, ..., y→z, and z→a. (Note that the shifting 'wraps' back around.) Thus the encoded message would be: \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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026amp; ftdbqf.\\\"\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 correct answer would comprise:\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[s.shift = uint8(1)  \\ns.message = 'Cancel Operation Phoenix immediately \u0026 escape.']]\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:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable and doesn't generate excessive text output). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand.\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\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \\\"too slow\\\".\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\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\u003eNext problem: \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/44356\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Orthos\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\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\u003eStatistics on solutions submitted as at 15 October 2017:\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eFastest wall time to decode 5000 messages = 93 milliseconds\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , for\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/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSolution 1279303\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, with a size-based score of 40.\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSmallest size-based score = 38\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , for\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/44351-code-breaker-part-i-operation-phoenix/solutions/1278780\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSolution 1278780\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, for which wall time to decode 5000 messages = 515 milliseconds.\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\u003eBest combined score = 49, for\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/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSolution 1279303\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":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":154,"title":"Reverse Boggle","description":"Description\r\nIn the classic Parker Brothers game Boggle, players find words from a 4x4 game board of letters. This exercise is to make sure that a particular solution to a boggle board is actually available on the board.\r\nThe program does not need to check to make sure if the input word is a valid english word. Furthermore, all inputs will be in all uppercase, so the user does not need to check/convert for case differences. The game board will always be 4x4.\r\nNote: This does not perfectly align with the rules of Boggle. Specifically, all solutions in the original game must be 3 or more letters, which this problem is not asking to account for, and the atomic \"Qu\" is present (which I have avoided in the test suite).\r\nHappy MATLABing!\r\nExample\r\n    x = ['TIPE'\r\n         'YECV'\r\n         'LSRA'\r\n         'WOTU'];\r\n    y = 'RACIEST';\r\n    TF = true;","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: 387.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 193.8px; transform-origin: 407px 193.8px; vertical-align: baseline; \"\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: 40.5px 8px; transform-origin: 40.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eDescription\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: 112px 8px; transform-origin: 112px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIn the classic Parker Brothers game\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 = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eBoggle\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: 247px 8px; transform-origin: 247px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, players find words from a 4x4 game board of letters. This exercise is to make sure that a particular solution to a boggle board is actually available on the board.\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: 41px 8px; transform-origin: 41px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe program\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\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: 27.5px 8px; transform-origin: 27.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003edoes not\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: 311px 8px; transform-origin: 311px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e need to check to make sure if the input word is a valid english word. Furthermore, all inputs will be in all uppercase, so the user does not need to check/convert for case differences. The game board will always be 4x4.\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: 370px 8px; transform-origin: 370px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNote: This does not perfectly align with the rules of Boggle. Specifically, all solutions in the original game must be 3 or more letters, which this problem is not asking to account for, and the atomic \"Qu\" is present (which I have avoided in the test suite).\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: 61px 8px; transform-origin: 61px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHappy MATLABing!\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: 29.5px 8px; transform-origin: 29.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExample\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 122.6px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 61.3px; transform-origin: 404px 61.3px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; tab-size: 4; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 36px 8.5px; transform-origin: 36px 8.5px; \"\u003e    x = [\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 24px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 24px 8.5px; \"\u003e'TIPE'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; tab-size: 4; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 36px 8.5px; transform-origin: 36px 8.5px; \"\u003e         \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 24px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 24px 8.5px; \"\u003e'YECV'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; tab-size: 4; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 36px 8.5px; transform-origin: 36px 8.5px; \"\u003e         \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 24px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 24px 8.5px; \"\u003e'LSRA'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 68px 8.5px; tab-size: 4; transform-origin: 68px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 36px 8.5px; transform-origin: 36px 8.5px; \"\u003e         \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 24px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 24px 8.5px; \"\u003e'WOTU'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 8px 8.5px; transform-origin: 8px 8.5px; \"\u003e];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 72px 8.5px; tab-size: 4; transform-origin: 72px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e    y = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 36px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003e'RACIEST'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; tab-size: 4; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e    TF = true;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tf = boggle_checker(x,y)\r\n  tf = true;\r\nend","test_suite":"%%\r\nx = ['TIPE'\r\n     'YECV'\r\n     'LSRA'\r\n     'WOTU'];\r\ny = 'RACIEST';\r\nassert(isequal(boggle_checker(x,y),true))\r\n\r\n%%\r\nx = ['TIPE'\r\n     'YECV'\r\n     'LSRA'\r\n     'WOTU'];\r\ny = 'RACIESTS';\r\nassert(isequal(boggle_checker(x,y),false))\r\n\r\n%%\r\nx = ['TIPE'\r\n     'YECV'\r\n     'LSRA'\r\n     'WOTU'];\r\ny = 'RACIESTW';\r\nassert(isequal(boggle_checker(x,y),false))\r\n\r\n%%\r\nx = ['TIPE'\r\n     'YECV'\r\n     'LSRA'\r\n     'WOTU'];\r\ny = 'AUTOLYTIC';\r\nassert(isequal(boggle_checker(x,y),true))\r\n\r\n%%\r\nx = ['TIPE'\r\n     'YECV'\r\n     'LSRA'\r\n     'WOTU'];\r\ny = 'RESTAR';\r\nassert(isequal(boggle_checker(x,y),false))\r\n\r\n%%\r\nx = ['OCEW'\r\n     'LRIR'\r\n     'GYSI'\r\n     'KREM'];\r\ny = 'SIRI';\r\nassert(isequal(boggle_checker(x,y),true))\r\n\r\n%%\r\nx = ['OCEW'\r\n     'LRIR'\r\n     'GYSI'\r\n     'KREM'];\r\ny = 'SIRIM';\r\nassert(isequal(boggle_checker(x,y),true))\r\n\r\n%%\r\nx = ['OCEW'\r\n     'LRIR'\r\n     'GYSI'\r\n     'KREM'];\r\ny = 'GLORY';\r\nassert(isequal(boggle_checker(x,y),true))\r\n\r\n%%\r\nx = ['OCEW'\r\n     'LRIR'\r\n     'GYSI'\r\n     'KREM'];\r\ny = 'ROME';\r\nassert(isequal(boggle_checker(x,y),false))","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":134,"edited_by":223089,"edited_at":"2023-02-02T11:43:47.000Z","deleted_by":null,"deleted_at":null,"solvers_count":60,"test_suite_updated_at":"2023-02-02T11:43:47.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2012-01-28T22:27:00.000Z","updated_at":"2026-04-02T08:30:49.000Z","published_at":"2012-02-01T01:02:17.000Z","restored_at":null,"restored_by":null,"spam":null,"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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eDescription\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\u003eIn the classic Parker Brothers game\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=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eBoggle\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, players find words from a 4x4 game board of letters. This exercise is to make sure that a particular solution to a boggle board is actually available on the 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe program\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edoes not\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e need to check to make sure if the input word is a valid english word. Furthermore, all inputs will be in all uppercase, so the user does not need to check/convert for case differences. The game board will always be 4x4.\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\u003eNote: This does not perfectly align with the rules of Boggle. Specifically, all solutions in the original game must be 3 or more letters, which this problem is not asking to account for, and the atomic \\\"Qu\\\" is present (which I have avoided in the test suite).\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\u003eHappy MATLABing!\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    x = ['TIPE'\\n         'YECV'\\n         'LSRA'\\n         'WOTU'];\\n    y = 'RACIEST';\\n    TF = true;]]\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":44356,"title":"Code breaker, Part II:  Operation Orthos","description":"You have been tasked with decoding several batches of coded messages that have been intercepted.  \r\n\r\nBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003chttps://en.wikipedia.org/wiki/Caesar_cipher Caesar cipher\u003e (a type of \u003chttps://en.wikipedia.org/wiki/Substitution_cipher substitution cipher\u003e), an example of which is the \u003chttps://en.wikipedia.org/wiki/ROT13 ROT13 cipher\u003e (discussed in \u003chttps://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher Cody Challenge Problem 78\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between batches of messages — although it will be the same for all messages in a batch (also, here you need to decode, not encode).  \r\n\r\nYou can also assume that the original batch of messages will relate to an activity that is referred to by those involved as \"Operation Orthos\". However, in their secret internal communications they might not use this exact phrase at all, nor this exact capitalisation.  Therefore you should seek _simultaneous_ occurrence of the separate words \"Operation\" and \"Orthos\" (with any capitalisation) in messages within the given batch.  \r\n\r\nYour task is to crack the codes and report back in a \u003chttp://au.mathworks.com/help/matlab/ref/struct.html structure array\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e];  (2)  the decoded messages [as a \u003chttp://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta cell array\u003e (containing \u003chttp://au.mathworks.com/help/matlab/ref/char.html character arrays\u003e)].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".  \r\n\r\nEXAMPLE\r\n\r\nSuppose the batch contained two encoded messages — _\"qspdffe x/ pqfsbujpo\"_ and _\"Psuipt jt HP!\"_ (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the original messages would have been:  _\"proceed w/ operation\"_ and _\"Orthos is GO!\"_ .\r\n\r\nThe correct answer would comprise:  \r\n\r\n  s.shift = uint8(1)  \r\n  s.message = {'proceed w/ operation', 'Orthos is GO!'}\r\n\r\nIf the batch of messages cannot be decoded when following the above assumptions, then simply return 'scalar' \u003chttp://au.mathworks.com/help/matlab/ref/nan.html NaN\u003e in both fields (no need for a cell array).  \r\n\r\n|Note:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)|  \r\n\r\nTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".  \r\n\r\n----------\r\n\r\nPrevious problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351 Operation Phoenix\u003e.  Next problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44383 Operation Xiangliu\u003e.","description_html":"\u003cp\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\u003c/p\u003e\u003cp\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003ca href = \"https://en.wikipedia.org/wiki/Caesar_cipher\"\u003eCaesar cipher\u003c/a\u003e (a type of \u003ca href = \"https://en.wikipedia.org/wiki/Substitution_cipher\"\u003esubstitution cipher\u003c/a\u003e), an example of which is the \u003ca href = \"https://en.wikipedia.org/wiki/ROT13\"\u003eROT13 cipher\u003c/a\u003e (discussed in \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\"\u003eCody Challenge Problem 78\u003c/a\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between batches of messages — although it will be the same for all messages in a batch (also, here you need to decode, not encode).\u003c/p\u003e\u003cp\u003eYou can also assume that the original batch of messages will relate to an activity that is referred to by those involved as \"Operation Orthos\". However, in their secret internal communications they might not use this exact phrase at all, nor this exact capitalisation.  Therefore you should seek \u003ci\u003esimultaneous\u003c/i\u003e occurrence of the separate words \"Operation\" and \"Orthos\" (with any capitalisation) in messages within the given batch.\u003c/p\u003e\u003cp\u003eYour task is to crack the codes and report back in a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/struct.html\"\u003estructure array\u003c/a\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e];  (2)  the decoded messages [as a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\"\u003ecell array\u003c/a\u003e (containing \u003ca href = \"http://au.mathworks.com/help/matlab/ref/char.html\"\u003echaracter arrays\u003c/a\u003e)].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".\u003c/p\u003e\u003cp\u003eEXAMPLE\u003c/p\u003e\u003cp\u003eSuppose the batch contained two encoded messages — \u003ci\u003e\"qspdffe x/ pqfsbujpo\"\u003c/i\u003e and \u003ci\u003e\"Psuipt jt HP!\"\u003c/i\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the original messages would have been:  \u003ci\u003e\"proceed w/ operation\"\u003c/i\u003e and \u003ci\u003e\"Orthos is GO!\"\u003c/i\u003e .\u003c/p\u003e\u003cp\u003eThe correct answer would comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(1)  \r\ns.message = {'proceed w/ operation', 'Orthos is GO!'}\r\n\u003c/pre\u003e\u003cp\u003eIf the batch of messages cannot be decoded when following the above assumptions, then simply return 'scalar' \u003ca href = \"http://au.mathworks.com/help/matlab/ref/nan.html\"\u003eNaN\u003c/a\u003e in both fields (no need for a cell array).\u003c/p\u003e\u003cp\u003e\u003ctt\u003eNote:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003ePrevious problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351\"\u003eOperation Phoenix\u003c/a\u003e.  Next problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44383\"\u003eOperation Xiangliu\u003c/a\u003e.\u003c/p\u003e","function_template":"function s = decode(x)\r\n  s = x;\r\nend","test_suite":"%% NOTE:  \r\n% This test suite can be updated if inappropriate 'hacks' \r\n% are discovered in any submitted solutions, \r\n% so the assessment of your submission may therefore change over time.  \r\nRE = regexp(fileread('decode.m'), '\\w+', 'match');\r\ntabooWords = {'ans', 'assert', 'freepass', 'tic'};\r\ntestResult = cellfun( @(z) ismember(z, tabooWords), RE );\r\nmsg = ['Please do not do that in your code!' char([10 13]) ...\r\n    'Found: ' strjoin(RE(testResult)) '.' char([10 13]) ...\r\n    'Banned word.' char([10 13])];\r\nassert(~any(  cellfun( @(z) ismember(z, tabooWords), RE )  ), msg)\r\n\r\n\r\n%% Test 1\r\nx =                 {'qspdffe x/ pqfsbujpo', 'Psuipt jt HP!'};\r\ns_correct.shift = uint8(1);\r\ns_correct.message = {'proceed w/ operation', 'Orthos is GO!'};\r\ns = decode(x);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message{1}, s_correct.message{1}) )\r\nassert( isequal(s.message{2}, s_correct.message{2}) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(s, s_correct) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'cell') )\r\nassert( isequal(class(s.message{1}), 'char') )\r\n\r\n\r\n%% Test 2\r\nx =                 {'Hfqq Ons ts 555-7839 FXFU.', 'twymtx nx ts mtqi', 'bfnynsl ktw dtzw fianhj', 'TUJWFYNTS UTXYUTSJI'};\r\ns_correct.shift = uint8(5);\r\ns_correct.message = {'Call Jin on 555-7839 ASAP.', 'orthos is on hold', 'waiting for your advice', 'OPERATION POSTPONED'};\r\ns = decode(x);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 3\r\nx =                 {'Ocz kvnnrjmy rvn xcvibzy: \"Knpdko\" oj \"Gjlzgk\".', 'Jkzmvodji Kcjzids rvn npxxznnapg. Izso rdgg wz Jmocjn.', 'Edi Uvkxgzout rdgg wz gzvydib Ozvh V'};\r\ns_correct.shift = uint8(21);\r\ns_correct.message = {'The password was changed: \"Psuipt\" to \"Loqelp\".', 'Operation Phoenix was successful. Next will be Orthos.', 'Jin Zapcletzy will be leading Team A'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 4\r\nx =                 {'bxmzzuzs r/ adftae az fdmow', 'adftae etxp oaybxqfq uz 2 iwe', 'abqdmfuaz pmfq eturfqp nmow 2 p.', 'naawe dqoquhqp. fwe Vuz' };\r\ns_correct.shift = uint8(12);\r\ns_correct.message = {'planning f/ orthos on track', 'orthos shld complete in 2 wks', 'operation date shifted back 2 d.', 'books received. tks Jin'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 5\r\nx =                 {'Hdsffafy xgj Ghwjslagf Gjlzgk zsk gxxauasddq ugeewfuwv.  Lzak oadd tw dwv tq Lwse S, kmhhgjlwv tq Lwse T sk fwwvwv.'};\r\ns_correct.shift = uint8(18);\r\ns_correct.message = {'Planning for Operation Orthos has officially commenced.  This will be led by Team A, supported by Team B as needed.'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 6\r\nx = {'Mncpyrgml Nfmclgv qryprcb rfpcc bywq yem.  Yjj ncpqmllcj ypc rm pckygl ml bsrw slrgj Mncpyrgml Nfmclgv gq amknjcrcb.'};\r\ns_correct.shift = nan;\r\ns_correct.message = nan;\r\ns = decode(x);\r\nassert( isnan(s.shift) )\r\nassert( isnan(s.message) )\r\n\r\n\r\n%% Test 7\r\nx =                 {'Iutloxskj vgyycuxj oy tuc \"Ruwkrv\".', 'Vrgt lux uxznuy ruuqy UQ, haz tkkj suxk $$$', 'Ksgor Pot Fgvirkzfe ut xacqxb@sgzncuxqy.ius xk. Zakyjge', 'Zgrqkj zu Zkgs H.  Ngvve zu yavvuxz uvkxgzout....', 'Xk. latjy, vry zxgtylkx zu giiuatz \"YZOBKDSYX\" - ZDY', 'jUT''Z cUXXE'};\r\ns_correct.shift = uint8(6);\r\ns_correct.message = {'Confirmed password is now \"Loqelp\".', 'Plan for orthos looks OK, but need more $$$', 'Email Jin Zapcletzy on ruwkrv@mathworks.com re. Tuesday', 'Talked to Team B.  Happy to support operation....', 'Re. funds, pls transfer to account \"STIVEXMSR\" - TXS', 'dON''T wORRY'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% TIMING \r\n% Note:  The Time Trial section does not check accuracy; that is done above.\r\n\r\n% Acknowledgements  \r\n% Portions of this timing test code were inspired by:\r\n% (1) Problem 937. \"Rubik's Mini Cube: Solve Randomized Cube in 11 Moves or Less; Score is by Time (msec)\" by Richard Zapor.\r\n% (2) Problem 2733. \"Evil Number\" by Jan Orwat.\r\n% (3) Feedback in comments from Peng Liu.\r\n% (4) Problem Problem 1237. \"It's race time! Write a faster function than the test suite call of unique().\" by Jeremy.\r\n\r\n% INITIALISE\r\nx = {'qspdffe x/ pqfsbujpo', 'Psuipt jt HP!'};\r\nqSmall = 50;\r\nqBig = 10000;\r\n%cutoffTimeBig = 10;\r\n\r\n% EDIT (2018-06-17).  Reduced time to pose reasonable challenge.\r\n% Accounted for improving Cody server speed per Problem 44655.\r\ncutoffTimeBig = 3;    % Maximum allowable walltime (in seconds) to run function in a loop with qBig iterations.\r\ntRef = datetime('2018-06-17', 'InputFormat','yyyy-MM-dd');\r\ntNow = datetime('now');\r\nyearsElapsed = (datenum(tNow) - datenum(tRef)) / 365.24;\r\nfprintf('\\r\\n\\r\\n\\r\\nSubmission evaluated for speed on %s.\\r\\n', datestr(tNow, 'dd mmmm yyyy'))\r\nrInf = 0.2;   delta = cutoffTimeBig - rInf;  tau = 3.6;  % Data from Problem 44655, based on Problem 963.\r\nqBig = floor( qBig * (cutoffTimeBig - rInf) * exp(yearsElapsed/tau) / delta );\r\nfprintf('\\r\\n\\r\\n\\r\\nTo account for computational power increases over time, number of iterations increased to %u.\\r\\n', qBig)\r\n% END EDIT (2018-06-17)\r\n\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\n\r\n% *** PRELIMINARY TIMING WITH timeit ***\r\nfDecode = @()   decode(x);\r\ndt_timeit = timeit( fDecode );\r\nfprintf('APPROXIMATE time to decode %u message batches ~ %2.2f seconds, according to ''timeit''.\\n\\r', qBig, dt_timeit * qBig)\r\n\r\n% *** PRELIMINARY TIMING WITH SHORT LOOP ***\r\n% In case the submitted function has a lot of text output, \r\n% get an estimate based on just a few iterations\r\n% Initialise\r\nt0 = clock;\r\n\r\n% Loop\r\nfor i = 1 : qSmall\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0);\r\ndisp('     -----=====-----     ')\r\n%fprintf('Your wall time to decode %u message batches = %i seconds.\\n\\r', qSmall, floor(dt))\r\nfprintf('APPROXIMATE wall time to decode %u message batches ~ %2.2f seconds, by extrapolating from %u batches.\\n\\r', qBig, dt * qBig / qSmall, qSmall)\r\ndisp('     -----=====-----     ')\r\n\r\n% *** 'OFFICIAL' TIMING ***\r\n% Re-initialise timer\r\nt0 = clock;\r\nt0_cpu = cputime;\r\n\r\n% Loop\r\nfor i = 1 : qBig\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\ndisp('     -----=====|||||=====-----     ')\r\ndt = etime(clock, t0);\r\nfprintf('Your wall time to decode %u message batches = %2.2f seconds.\\n\\r', qBig, dt)\r\n\r\ndt_cpu = (cputime - t0_cpu);\r\nfprintf(' ( Your CPU time for this = %2.2f seconds. ) \\n\\r', dt_cpu)\r\n\r\n% Display (default) Cody size-based score.\r\nall_nodes = mtree('decode.m', '-file');\r\nsize_score = count(all_nodes);\r\nfprintf('Your Cody-standard size-based score = %i.\\n\\r', size_score)\r\n\r\n% Report revised performance score\r\ncombinedScore = size_score + round(dt * 10);\r\nfprintf('Your combined score = %i.\\n\\r', combinedScore)\r\ndisp('     -----=====|||||=====-----     ')\r\n\r\n% Now disallow any candidate solutions that are TOO SLOW!\r\nif dt \u003e cutoffTimeBig, \r\n    fprintf('Sorry, your submission is TOO SLOW.  It must be able to finish within %u seconds.\\n\\r', cutoffTimeBig)\r\nend;\r\n\r\nassert( dt \u003c= cutoffTimeBig )","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":"2018-06-17T14:03:55.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2017-10-03T06:52:32.000Z","updated_at":"2026-04-02T18:15:25.000Z","published_at":"2017-10-03T11:50:21.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\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\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\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple\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://en.wikipedia.org/wiki/Caesar_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCaesar cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (a type 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://en.wikipedia.org/wiki/Substitution_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esubstitution cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e), an example of which is the\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://en.wikipedia.org/wiki/ROT13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eROT13 cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (discussed in\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/78-implement-a-rot13-cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Challenge Problem 78\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e). As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026amp; numbers) are unchanged. Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between batches of messages — although it will be the same for all messages in a batch (also, here you need to decode, not encode).\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 can also assume that the original batch of messages will relate to an activity that is referred to by those involved as \\\"Operation Orthos\\\". However, in their secret internal communications they might not use this exact phrase at all, nor this exact capitalisation. Therefore you should seek\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esimultaneous\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e occurrence of the separate words \\\"Operation\\\" and \\\"Orthos\\\" (with any capitalisation) in messages within the given batch.\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\u003eYour task is to crack the codes and report back in a\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://au.mathworks.com/help/matlab/ref/struct.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estructure array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e: (1) the shifting parameter that had been used in the encoding [as\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://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e]; (2) the decoded messages [as a\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://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ecell array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (containing\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://au.mathworks.com/help/matlab/ref/char.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003echaracter arrays\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e)]. The name of the structure array shall be \\\"s\\\", with respective fields \\\"shift\\\" and \\\"message\\\".\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\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the batch contained two encoded messages —\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"qspdffe x/ pqfsbujpo\\\"\u003c/w:t\u003e\u003c/w:r\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:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Psuipt jt HP!\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied. In that case A→B, B→C, ..., Y→Z, and Z→A; similarly, a→b, b→c, ..., y→z, and z→a. (Note that the shifting 'wraps' back around.) Thus the original messages would have been: \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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"proceed w/ operation\\\"\u003c/w:t\u003e\u003c/w:r\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:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Orthos is GO!\\\"\u003c/w:t\u003e\u003c/w:r\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\u003eThe correct answer would comprise:\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[s.shift = uint8(1)  \\ns.message = {'proceed w/ operation', 'Orthos is GO!'}]]\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\u003eIf the batch of messages cannot be decoded when following the above assumptions, then simply return 'scalar'\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://au.mathworks.com/help/matlab/ref/nan.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eNaN\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e in both fields (no need for a cell array).\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:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\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\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \\\"too slow\\\".\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\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\u003ePrevious problem: \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/44351\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Phoenix\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: \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/44383\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Xiangliu\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":44383,"title":"Code breaker, Part III:  Operation Xiangliu","description":"You have been tasked with decoding several batches of coded messages that have been intercepted.  \r\n\r\nBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003chttps://en.wikipedia.org/wiki/Caesar_cipher Caesar cipher\u003e (a type of \u003chttps://en.wikipedia.org/wiki/Substitution_cipher substitution cipher\u003e), an example of which is the \u003chttps://en.wikipedia.org/wiki/ROT13 ROT13 cipher\u003e (discussed in \u003chttps://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher Cody Challenge Problem 78\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation, numbers, accented letters) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and will vary _between_ (not within) batches — also, here you need to decode, not encode.  \r\n\r\nThese latest activities that you are investigating have been nicknamed 'Operation Xiangliu' by your own organisation.  A few decoding options are at your organisation's disposal:  \r\n\r\n# Test the candidate decodings against all words in a large dictionary — this could work, but it is very slow.\r\n# Test the candidate decodings for the appearance of a name or phrase that is certain to appear regularly (e.g. \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351 \"Operation Phoenix\"\u003e) — unfortunately as yet there is not enough knowledge of the activities to be sure of a suitable name or phrase to use.  \r\n# Test the candidate decodings against all words in a short list comprising, say, the hundred most frequently used English words.\r\n\r\nThe *third option* will be faster than the first option, and more reliable than the second option, so this is the approach you will be taking.  \r\n\r\nYou have been careful to avoid using 'lemmatised' lists (which contain e.g. the verb \"to be\", rather than the various inflected forms such as \"am\", \"is\", \"are\") like those based on the \u003chttps://web.archive.org/web/20111226085859/http://oxforddictionaries.com/words/the-oec-facts-about-the-language OEC\u003e or \u003chttps://www.wordfrequency.info/free.asp?s=y COCA\u003e, and after setting aside \u003chttp://world-english.org/english500.htm another list\u003e you finally choose the \u003chttp://ucrel.lancs.ac.uk/bncfreq/samples/120.pdf list based on the BNC\u003e as the most reliable, and will use the first 100 words on that list.  \r\nThis list will be available for you to access as an input variable, |bncWordlist|, to your function. Note: (i) some entries on the list are morphemes (e.g. \"\u0026#x200A;n't\u0026#x200A;\" and \"\u0026#x200A;'s\u0026#x200A;\") rather than words;  (ii) some entries appear more than once (representing different grammatical word classes).  Of course, in the original messages any capitalisation might be used.  \r\n\r\nYou have been instructed that your 'certitude' (degree of confidence) in the decoding must be reported for each batch, and shall depend proportionally upon the sum of the characters for the words/morphemes in the decoded message that match words/morphemes in |bncWordlist|.  Being able to match words/morphemes accounting for three-tenths of the characters (excluding spaces) shall correspond to 100% certitude;  matching three-twentieths would be 50% certitude, and so on.  Certitude shall be reported as a percentage, rounded _up_ to the nearest integer, not greater than 100.  You need to maximise your certitude for each batch by appropriate choice of the shifting parameter.   If there are multiple shifts of equal certitude, report both options on different rows (arranged in order of ascending shift parameter).\r\n\r\nYour task is to crack the codes and report back in a \u003chttp://au.mathworks.com/help/matlab/ref/struct.html structure array\u003e: \u0026nbsp; (1) the shifting parameter that had been used in the encoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e] (usually scalar, but may be column vector); \u0026nbsp; (2) the decoded messages [as a \u003chttp://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta cell array\u003e (containing \u003chttp://au.mathworks.com/help/matlab/ref/char.html character arrays\u003e)] (usually an array with a single row, but occasionally with multiple rows); \u0026nbsp; (3) your 'certitude' in the decoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e] (always scalar).  \r\nThe name of the structure array shall be |s|, with respective fields |shift|, |message|, and |certitude|.  \r\n\r\n*EXAMPLE 1*\r\n\r\nSuppose the batch contained two encoded messages — _\"Vomftt qvstvfe, pqfo op eppst.\"_ and _\"Ffmt dbo ljmm, opu pomz xpvoe.\"_ (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  \r\nThus the original messages would have been:  _\"Unless pursued, open no doors.\"_ and _\"Eels can kill, not only wound.\"_ .  Twelve of the 51 characters have been matched:  \"no\", \"can\", \"not\", and \"only\".  \r\n\r\nThe correct answer would therefore comprise:  \r\n\r\n  s.shift = uint8(1)  \r\n  s.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'}\r\n  s.certitude = uint8(79)\r\n\r\n*EXAMPLE 2*\r\n\r\nSuppose the batch contained one encoded message — _\"Oa oqvvq'u cnycau dggp: \"Ctu itcvkc ctvku\".\"_ (provided as a character array within a cell array) — and a (right-shifting) ROT2 cipher had been applied.  In that case A→C, B→D, ..., Y→A, and Z→B;  similarly, a→c, b→d, ..., y→a, and z→b.  \r\nThus the original message would have been:  _\"My motto's always been: \"Ars gratia artis\".\"_ .  Eight of the 37 characters have been matched: \"My\", \"\u0026#x200A;'s\u0026#x200A;\", and \"been\".  Note carefully that:  \"\u0026#x200A;'s\u0026#x200A;\" should only be matched once;  \"to\" (in motto), \"be\" (in been), \"at\" (in gratia), \"is\" (in artis) and \"a\" (passim) should _not_ be matched at all;  and \"\u0026#x200A;'\u0026#x200A;\" will only ever be used as an apostrophe (never as a quotation mark).  \r\n\r\nThe correct answer would therefore comprise:  \r\n\r\n  s.shift = uint8(2)  \r\n  s.message = {'My motto''s always been: \"Ars gratia artis\".'}\r\n  s.certitude = uint8(73)\r\n\r\nIf the batch of messages cannot be decoded when following the above assumptions, then return the original encoded message(s) unchanged, with a shift of zero and a certitude of zero.  \r\n\r\n|Note:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)|  \r\n\r\nTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".  \r\n\r\n----------\r\n\r\nPrevious problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44356 Operation Orthos\u003e.  Next problem:  TBA.","description_html":"\u003cp\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\u003c/p\u003e\u003cp\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003ca href = \"https://en.wikipedia.org/wiki/Caesar_cipher\"\u003eCaesar cipher\u003c/a\u003e (a type of \u003ca href = \"https://en.wikipedia.org/wiki/Substitution_cipher\"\u003esubstitution cipher\u003c/a\u003e), an example of which is the \u003ca href = \"https://en.wikipedia.org/wiki/ROT13\"\u003eROT13 cipher\u003c/a\u003e (discussed in \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\"\u003eCody Challenge Problem 78\u003c/a\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation, numbers, accented letters) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and will vary \u003ci\u003ebetween\u003c/i\u003e (not within) batches — also, here you need to decode, not encode.\u003c/p\u003e\u003cp\u003eThese latest activities that you are investigating have been nicknamed 'Operation Xiangliu' by your own organisation.  A few decoding options are at your organisation's disposal:\u003c/p\u003e\u003col\u003e\u003cli\u003eTest the candidate decodings against all words in a large dictionary — this could work, but it is very slow.\u003c/li\u003e\u003cli\u003eTest the candidate decodings for the appearance of a name or phrase that is certain to appear regularly (e.g. \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351\"\u003e\"Operation Phoenix\"\u003c/a\u003e) — unfortunately as yet there is not enough knowledge of the activities to be sure of a suitable name or phrase to use.\u003c/li\u003e\u003cli\u003eTest the candidate decodings against all words in a short list comprising, say, the hundred most frequently used English words.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eThe \u003cb\u003ethird option\u003c/b\u003e will be faster than the first option, and more reliable than the second option, so this is the approach you will be taking.\u003c/p\u003e\u003cp\u003eYou have been careful to avoid using 'lemmatised' lists (which contain e.g. the verb \"to be\", rather than the various inflected forms such as \"am\", \"is\", \"are\") like those based on the \u003ca href = \"https://web.archive.org/web/20111226085859/http://oxforddictionaries.com/words/the-oec-facts-about-the-language\"\u003eOEC\u003c/a\u003e or \u003ca href = \"https://www.wordfrequency.info/free.asp?s=y\"\u003eCOCA\u003c/a\u003e, and after setting aside \u003ca href = \"http://world-english.org/english500.htm\"\u003eanother list\u003c/a\u003e you finally choose the \u003ca href = \"http://ucrel.lancs.ac.uk/bncfreq/samples/120.pdf\"\u003elist based on the BNC\u003c/a\u003e as the most reliable, and will use the first 100 words on that list.  \r\nThis list will be available for you to access as an input variable, \u003ctt\u003ebncWordlist\u003c/tt\u003e, to your function. Note: (i) some entries on the list are morphemes (e.g. \"\u0026#x200A;n't\u0026#x200A;\" and \"\u0026#x200A;'s\u0026#x200A;\") rather than words;  (ii) some entries appear more than once (representing different grammatical word classes).  Of course, in the original messages any capitalisation might be used.\u003c/p\u003e\u003cp\u003eYou have been instructed that your 'certitude' (degree of confidence) in the decoding must be reported for each batch, and shall depend proportionally upon the sum of the characters for the words/morphemes in the decoded message that match words/morphemes in \u003ctt\u003ebncWordlist\u003c/tt\u003e.  Being able to match words/morphemes accounting for three-tenths of the characters (excluding spaces) shall correspond to 100% certitude;  matching three-twentieths would be 50% certitude, and so on.  Certitude shall be reported as a percentage, rounded \u003ci\u003eup\u003c/i\u003e to the nearest integer, not greater than 100.  You need to maximise your certitude for each batch by appropriate choice of the shifting parameter.   If there are multiple shifts of equal certitude, report both options on different rows (arranged in order of ascending shift parameter).\u003c/p\u003e\u003cp\u003eYour task is to crack the codes and report back in a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/struct.html\"\u003estructure array\u003c/a\u003e: \u0026nbsp; (1) the shifting parameter that had been used in the encoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e] (usually scalar, but may be column vector); \u0026nbsp; (2) the decoded messages [as a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\"\u003ecell array\u003c/a\u003e (containing \u003ca href = \"http://au.mathworks.com/help/matlab/ref/char.html\"\u003echaracter arrays\u003c/a\u003e)] (usually an array with a single row, but occasionally with multiple rows); \u0026nbsp; (3) your 'certitude' in the decoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e] (always scalar).  \r\nThe name of the structure array shall be \u003ctt\u003es\u003c/tt\u003e, with respective fields \u003ctt\u003eshift\u003c/tt\u003e, \u003ctt\u003emessage\u003c/tt\u003e, and \u003ctt\u003ecertitude\u003c/tt\u003e.\u003c/p\u003e\u003cp\u003e\u003cb\u003eEXAMPLE 1\u003c/b\u003e\u003c/p\u003e\u003cp\u003eSuppose the batch contained two encoded messages — \u003ci\u003e\"Vomftt qvstvfe, pqfo op eppst.\"\u003c/i\u003e and \u003ci\u003e\"Ffmt dbo ljmm, opu pomz xpvoe.\"\u003c/i\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  \r\nThus the original messages would have been:  \u003ci\u003e\"Unless pursued, open no doors.\"\u003c/i\u003e and \u003ci\u003e\"Eels can kill, not only wound.\"\u003c/i\u003e .  Twelve of the 51 characters have been matched:  \"no\", \"can\", \"not\", and \"only\".\u003c/p\u003e\u003cp\u003eThe correct answer would therefore comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(1)  \r\ns.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'}\r\ns.certitude = uint8(79)\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eEXAMPLE 2\u003c/b\u003e\u003c/p\u003e\u003cp\u003eSuppose the batch contained one encoded message — \u003ci\u003e\"Oa oqvvq'u cnycau dggp: \"Ctu itcvkc ctvku\".\"\u003c/i\u003e (provided as a character array within a cell array) — and a (right-shifting) ROT2 cipher had been applied.  In that case A→C, B→D, ..., Y→A, and Z→B;  similarly, a→c, b→d, ..., y→a, and z→b.  \r\nThus the original message would have been:  \u003ci\u003e\"My motto's always been: \"Ars gratia artis\".\"\u003c/i\u003e .  Eight of the 37 characters have been matched: \"My\", \"\u0026#x200A;'s\u0026#x200A;\", and \"been\".  Note carefully that:  \"\u0026#x200A;'s\u0026#x200A;\" should only be matched once;  \"to\" (in motto), \"be\" (in been), \"at\" (in gratia), \"is\" (in artis) and \"a\" (passim) should \u003ci\u003enot\u003c/i\u003e be matched at all;  and \"\u0026#x200A;'\u0026#x200A;\" will only ever be used as an apostrophe (never as a quotation mark).\u003c/p\u003e\u003cp\u003eThe correct answer would therefore comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(2)  \r\ns.message = {'My motto''s always been: \"Ars gratia artis\".'}\r\ns.certitude = uint8(73)\r\n\u003c/pre\u003e\u003cp\u003eIf the batch of messages cannot be decoded when following the above assumptions, then return the original encoded message(s) unchanged, with a shift of zero and a certitude of zero.\u003c/p\u003e\u003cp\u003e\u003ctt\u003eNote:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003ePrevious problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44356\"\u003eOperation Orthos\u003c/a\u003e.  Next problem:  TBA.\u003c/p\u003e","function_template":"% Comments are nice, aren't they....\r\nfunction s = decode(x, bncWordlist)\r\nend","test_suite":"%% NOTE:  \r\n% This test suite can be updated if inappropriate 'hacks' \r\n% are discovered in any submitted solutions.\r\n% The assessment of your submission may therefore change over time.  \r\n\r\nglobal bncWordlist\r\nbncWordlist = {'the', 'of', 'and', 'a', 'in', 'to', 'it', 'is', 'to', 'was', ...\r\n    'I', 'for', 'that', 'you', 'he', 'be', 'with', 'on', 'by', 'at', ...\r\n    'have', 'are', 'not', 'this', '''s', 'but', 'had', 'they', 'his', ...\r\n    'from', 'she', 'that', 'which', 'or', 'we', '''s', 'an', 'n''t', 'were', ...\r\n    'as', 'do', 'been', 'their', 'has', 'would', 'there', 'what', 'will', 'all', ...\r\n    'if', 'can', 'her', 'said', 'who', 'one', 'so', 'up', 'as', 'them', 'some', ...\r\n    'when', 'could', 'him', 'into', 'its', 'then', 'two', 'out', 'time', ...\r\n    'my', 'about', 'did', 'your', 'now', 'me', 'no', 'other', 'only', 'just', ...\r\n    'more', 'these', 'also', 'people', 'know', 'any', 'first', 'see', 'very', 'new', ...\r\n    'may', 'well', 'should', 'her', 'like', 'than', 'how', 'get', 'way', 'one', 'our'};\r\n\r\n\r\n%% Anti-hacking\r\n% EDIT (2019-07-02). Anti-hacking provision\r\n% Ensure only builtin functions will be called.\r\n! rm -v fileread.m\r\n! rm -v assert.m\r\n% END EDIT (2019-07-02)\r\n% EDIT (2018-06-18).  Anti-hacking provision\r\nRE = regexp(fileread('decode.m'), '\\w+', 'match');\r\ntabooWords = {'ans', 'assert', 'freepass', 'tic'};\r\ntestResult = cellfun( @(z) ismember(z, tabooWords), RE );\r\nmsg = ['Please do not do that in your code!' char([10 13]) ...\r\n    'Found: ' strjoin(RE(testResult)) '.' char([10 13]) ...\r\n    'Banned word.' char([10 13])];\r\nassert(~any(  cellfun( @(z) ismember(z, tabooWords), RE )  ), msg)\r\n\r\nfor j = 1 : randi(10)\r\n    decode({'Pizza for dinner.'}, {'mozzarella', 'mushrooms'});\r\nend;\r\n% END EDIT (2018-06-18)\r\n\r\n\r\n%% Test 1\r\nglobal bncWordlist\r\nx =                 {'Vomftt qvstvfe, pqfo op eppst.', 'Ffmt dbo ljmm, opu pomz xpvoe.'};\r\ns_correct.shift = uint8(1);\r\ns_correct.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'};\r\ns_correct.certitude = uint8(79);\r\ns = decode(x, bncWordlist);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.' )\r\nassert( isequal(s.message{1}, s_correct.message{1}), 'Wrong message{1}.' )\r\nassert( isequal(s.message{2}, s_correct.message{2}), 'Wrong message{2}.' )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.' )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.' )\r\nassert( isequal(s, s_correct), 'Wrong s.' )\r\nassert( isequal(class(s.shift), 'uint8'), 'Wrong class.' )\r\nassert( isequal(class(s.message), 'cell'), 'Wrong class.'  )\r\nassert( isequal(class(s.message{1}), 'char'), 'Wrong class.'  )\r\nassert( isequal(class(s.certitude), 'uint8'), 'Wrong class.'  )\r\n\r\n\r\n%% Test 2\r\nglobal bncWordlist\r\nx =                 {'Doo zduiduh lv edvhg rq ghfhswlrq.', ...\r\n    'Khqfh, zkhq deoh wr dwwdfn, zh pxvw vhhp xqdeoh;  zkhq xvlqj rxu irufhv, zh pxvw vhhp lqdfwlyh;  zkhq zh duh qhdu, zh pxvw pdnh wkh hqhpb eholhyh zh duh idu dzdb; zkhq idu dzdb, zh pxvw pdnh klp eholhyh zh duh qhdu.'};\r\ns_correct.shift = uint8(3);\r\ns_correct.message = {'All warfare is based on deception.', ...\r\n    'Hence, when able to attack, we must seem unable;  when using our forces, we must seem inactive;  when we are near, we must make the enemy believe we are far away; when far away, we must make him believe we are near.'};\r\ns_correct.certitude = uint8(95);\r\ns = decode(x, bncWordlist);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 3\r\nglobal bncWordlist\r\nx =                 {'Elia lrq yxfqp ql bkqfzb qeb bkbjv.  Cbfdk afploabo, xka zorpe efj.', ...\r\n    'Fc eb fp pbzrob xq xii mlfkqp, yb mobmxoba clo efj.  Fc eb fp fk prmboflo pqobkdqe, bsxab efj.'};\r\ns_correct.shift = uint8(23);\r\ns_correct.message = {'Hold out baits to entice the enemy.  Feign disorder, and crush him.', ...\r\n    'If he is secure at all points, be prepared for him.  If he is in superior strength, evade him.'};\r\ns_correct.certitude = uint8(100);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 4\r\nglobal bncWordlist\r\nx =                 {'Ax qgmj ghhgfwfl ak gx uzgdwjau lwehwj, kwwc lg ajjalslw zae.  Hjwlwfv lg tw owsc, lzsl zw esq yjgo sjjgysfl.', ...\r\n    'Ax zw ak lscafy zak wskw, yanw zae fg jwkl.', ...\r\n    'Ax zak xgjuwk sjw mfalwv, kwhsjslw lzwe.', ...\r\n    'Sllsuc zae ozwjw zw ak mfhjwhsjwv, shhwsj ozwjw qgm sjw fgl wphwulwv.'};\r\ns_correct.shift = uint8(18);\r\ns_correct.message = {'If your opponent is of choleric temper, seek to irritate him.  Pretend to be weak, that he may grow arrogant.', ...\r\n    'If he is taking his ease, give him no rest.', ...\r\n    'If his forces are united, separate them.', ...\r\n    'Attack him where he is unprepared, appear where you are not expected.'};\r\ns_correct.certitude = uint8(100);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 5\r\nglobal bncWordlist\r\nx =                 {'Aes cèwo vo foxd bémyvdo vo dowzy', ...\r\n    'Yx wo dbksdo no dbkîdbo aekxn to dbksdo no vk népksdo ne csvoxmo / Vo csvoxmo ocd n''yb, wksc t''ks mryscs vk mknoxmo', ... \r\n    'Mrkaeo wyd, mrkaeo zrbkco nsdc kfom owzrkco / Pksd no Mvkeno WM, vo mywwkxny no vk zrbkco', ...\r\n    'Mkb t''cesc ex WM n''kddkaeo, ckxc dsmc, kedroxdsaeo zkc ox dym / Zbêd à pbkzzob ceb vo lokd zyeb vo wyefowoxd rsz-ryz', ...\r\n    'Ne bkz n''kddkaeo aes pbkzzo, ézkdo, wkdbkaeo od zkdkdbkaeo / Zvec no ckxq de mvkaeoc, t''cesc WM noc Mkbzkdoc', ...\r\n    'Vo zénkqyqeo ox fyqeo ke xyw no myno Cyvkkb ye Mvkeno WM / Do zbyzyco n''émyedob moms / Ae''yx ézovvo voc fyiovvoc, nèc ae''yx cyxxo voc myxcyxxoc'};\r\ns_correct.shift = uint8([0 21]');\r\n% TIP:  The original message was not English!\r\ns_correct.message(1, :) = {'Aes cèwo vo foxd bémyvdo vo dowzy', ... \r\n    'Yx wo dbksdo no dbkîdbo aekxn to dbksdo no vk népksdo ne csvoxmo / Vo csvoxmo ocd n''yb, wksc t''ks mryscs vk mknoxmo', ... \r\n    'Mrkaeo wyd, mrkaeo zrbkco nsdc kfom owzrkco / Pksd no Mvkeno WM, vo mywwkxny no vk zrbkco', ... \r\n    'Mkb t''cesc ex WM n''kddkaeo, ckxc dsmc, kedroxdsaeo zkc ox dym / Zbêd à pbkzzob ceb vo lokd zyeb vo wyefowoxd rsz-ryz', ... \r\n    'Ne bkz n''kddkaeo aes pbkzzo, ézkdo, wkdbkaeo od zkdkdbkaeo / Zvec no ckxq de mvkaeoc, t''cesc WM noc Mkbzkdoc', ... \r\n    'Vo zénkqyqeo ox fyqeo ke xyw no myno Cyvkkb ye Mvkeno WM / Do zbyzyco n''émyedob moms / Ae''yx ézovvo voc fyiovvoc, nèc ae''yx cyxxo voc myxcyxxoc'}\r\ns_correct.message(2, :) = {'Fjx hèbt at ktci gérdait at itbed', ... \r\n    'Dc bt igpxit st igpîigt fjpcs yt igpxit st ap séupxit sj hxatcrt / At hxatcrt thi s''dg, bpxh y''px rwdxhx ap rpstcrt', ... \r\n    'Rwpfjt bdi, rwpfjt ewgpht sxih pktr tbewpht / Upxi st Rapjst BR, at rdbbpcsd st ap ewgpht', ... \r\n    'Rpg y''hjxh jc BR s''piipfjt, hpch ixrh, pjiwtcixfjt eph tc idr / Egêi à ugpeetg hjg at qtpi edjg at bdjktbtci wxe-wde', ... \r\n    'Sj gpe s''piipfjt fjx ugpeet, éepit, bpigpfjt ti epipigpfjt / Eajh st hpcv ij rapfjth, y''hjxh BR sth Rpgepith', ... \r\n    'At eéspvdvjt tc kdvjt pj cdb st rdst Hdappg dj Rapjst BR / It egdedht s''érdjitg rtrx / Fj''dc éetaat ath kdntaath, sèh fj''dc hdcct ath rdchdccth'}\r\ns_correct.certitude = uint8(11);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 6\r\nglobal bncWordlist\r\nx =                 {'Brvdujcnm mrbxamna yxbcdujcnb ynaonlc mrblryurwn;  brvdujcnm onja yxbcdujcnb lxdajpn;  brvdujcnm fnjtwnbb yxbcdujcnb bcanwpcq.' ...\r\n    'X mrerwn jac xo bdkcunch jwm bnlanlh!'};\r\ns_correct.shift = uint8(9);\r\ns_correct.message = {'Simulated disorder postulates perfect discipline;  simulated fear postulates courage;  simulated weakness postulates strength.' ...\r\n    'O divine art of subtlety and secrecy!'};\r\ns_correct.certitude = uint8(12);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 7\r\nglobal bncWordlist\r\nx =                 {'Nv treefk vekvi zekf rcczretv nzky evzxysfizex gizetvj lekzc nv riv rthlrzekvu nzky kyvzi uvjzxej.', ... \r\n    'Nv riv efk wzk kf cvru re ridp fe kyv drity lecvjj nv riv wrdzczri nzky kyv wrtv fw kyv tflekip — zkj dflekrzej reu wfivjkj, zkj gzkwrccj reu givtzgztvj, zkj drijyvj reu jnrdgj.', ... \r\n    'Nv jyrcc sv lerscv kf klie erklirc rumrekrxvj kf rttflek lecvjj nv drbv ljv fw cftrc xlzuvj.'};\r\ns_correct.shift = uint8(17);\r\ns_correct.message = {'We cannot enter into alliance with neighboring princes until we are acquainted with their designs.', ...  \r\n    'We are not fit to lead an army on the march unless we are familiar with the face of the country — its mountains and forests, its pitfalls and precipices, its marshes and swamps.', ...  \r\n    'We shall be unable to turn natural advantages to account unless we make use of local guides.'};\r\ns_correct.certitude = uint8(97);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 8\r\nglobal bncWordlist\r\nx =                 {'Oa oqvvq''u cnycau dggp: \"Ctu itcvkc ctvku\".'};\r\ns_correct.shift = uint8(2);\r\ns_correct.message = {'My motto''s always been: \"Ars gratia artis\".'};\r\ns_correct.certitude = uint8(73);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 9\r\nglobal bncWordlist\r\nx =                 {'Bestow rewards without regard 2 rule;  issue orders without regard 2 previous arrangements', ...\r\n    '\"Let advance bee richly rewarded \u0026 retreat bee heavily punished.\"', ...\r\n    ' Qwertyuiop''asdfghjkl.   Zxcvbnm-0123456789 = pass. ', ...\r\n    'αβγδ — persimon–apricot hybrid.', ...\r\n    'aIanasatbebydoheifinisitmemynoofonor''ssotoupweallandanyarebutcandidforgethadhasherhimhishowitsmaynewnotnown''toneouroutseeshethetwowaswaywhoyoualsobeenfromhaveintojustknowlikemoreonlysaidsomethanthatthemthentheythistimeverywellwerewhatwhenwillwithyouraboutcouldfirstothertheirtherethesewhichwouldpeopleshould'};\r\ns_correct.shift = uint8(0);\r\ns_correct.message = x;\r\ns_correct.certitude = uint8(0);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% TIMING \r\n% Note:  The Time Trial section does not check accuracy; that is done above.\r\n\r\n% Acknowledgements  \r\n% Portions of this timing test code were inspired by:\r\n% (1) Problem 937. \"Rubik's Mini Cube: Solve Randomized Cube in 11 Moves or Less; Score is by Time (msec)\" by Richard Zapor.\r\n% (2) Problem 2733. \"Evil Number\" by Jan Orwat.\r\n% (3) Feedback in comments from Peng Liu.\r\n% (4) Problem Problem 1237. \"It's race time! Write a faster function than the test suite call of unique().\" by Jeremy.\r\n\r\n% INITIALISE\r\nglobal bncWordlist\r\nx =                 {'Vomftt qvstvfe, pqfo op eppst.', 'Ffmt dbo ljmm, opu pomz xpvoe.'};\r\nqSmall = 50;\r\nqBig = 1000;\r\n%cutoffTimeBig = 10;    % Maximum allowable walltime (in seconds) to run function in a loop with qBig iterations.\r\n\r\n% EDIT (2018-06-17).  Reduced time [slightly] to pose reasonable challenge.\r\n% Accounted for improving Cody server speed per Problem 44655.\r\ncutoffTimeBig = 8;    % Maximum allowable walltime (in seconds) to run function in a loop with qBig iterations.\r\ntRef = datetime('2018-06-17', 'InputFormat','yyyy-MM-dd');\r\ntNow = datetime('now');\r\nyearsElapsed = (datenum(tNow) - datenum(tRef)) / 365.24;\r\ndisp(' . ');\r\nfprintf('\\r\\n\\r\\n\\r\\nSubmission evaluated for speed on %s.\\r\\n', datestr(tNow, 'dd mmmm yyyy'))\r\nrInf = 0.2;   delta = cutoffTimeBig - rInf;  tau = 3.6;  % Data from Problem 44655, based on Problem 963.\r\nqBig = ceil( qBig * (cutoffTimeBig - rInf) * exp(yearsElapsed/tau) / delta );\r\nfprintf('\\r\\n\\r\\n\\r\\nTo account for computational power increases over time, number of iterations increased to %u.\\r\\n', qBig)\r\n% END EDIT (2018-06-17)\r\n\r\n\r\n% *** PRELIMINARY TIMING WITH timeit ***\r\nfDecode = @()   decode(x, bncWordlist);\r\ndt_timeit = timeit( fDecode );\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\nfprintf('APPROXIMATE time to decode %u message batches ~ %2.2f seconds, according to ''timeit''.\\n\\r', qBig, dt_timeit * qBig)\r\n\r\n% *** PRELIMINARY TIMING WITH SHORT LOOP ***\r\n% In case the submitted function has a lot of text output, \r\n% get an estimate based on just a few iterations\r\n% Initialise\r\nt0 = clock;\r\n\r\n% Loop\r\nfor i = 1 : qSmall\r\n    solution = decode(x, bncWordlist);\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0);\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\n%fprintf('Your wall time to decode %u message batches = %i seconds.\\n\\r', qSmall, floor(dt))\r\nfprintf('APPROXIMATE wall time to decode %u message batches ~ %2.2f seconds, by extrapolating from %u batches.\\n\\r', qBig, dt * qBig / qSmall, qSmall)\r\n\r\n% *** 'OFFICIAL' TIMING ***\r\n% Re-initialise timer\r\nt0 = clock;\r\nt0_cpu = cputime;\r\n\r\n% Loop\r\nfor i = 1 : qBig\r\n    % EDIT (2018-06-17).   Ensure each case is unique.\r\n    characters = ['  ,   .' char(randi([97,122], [1,23]))];\r\n    x{2} = characters( randperm(30) );\r\n    % END EDIT (2018-06-17)\r\n    solution = decode(x, bncWordlist);\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0);\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\nfprintf('Your wall time to decode %u message batches = %2.2f seconds.\\n\\r', qBig, dt)\r\n\r\ndt_cpu = (cputime - t0_cpu);\r\nfprintf(' ( Your CPU time for this = %2.2f seconds. ) \\n\\r', dt_cpu)\r\n\r\n% Display (default) Cody size-based score.\r\nall_nodes = mtree('decode.m', '-file');\r\nsize_score = count(all_nodes);\r\nfprintf('Your Cody-standard size-based score = %i.\\n\\r', size_score)\r\n\r\n% Report revised performance score\r\ncombinedScore = size_score + round(dt * 10);\r\nfprintf('Your combined score = %i.\\n\\r', combinedScore)\r\ndisp('     -----=====|||||=====-----     ')\r\n\r\n% Now disallow any candidate solutions that are TOO SLOW!\r\nif dt \u003e cutoffTimeBig, \r\n    fprintf('Sorry, your submission is TOO SLOW.  It must be able to finish within %u seconds.\\n\\r', cutoffTimeBig)\r\nend;\r\n\r\nassert( dt \u003c= cutoffTimeBig, 'Exceeded time limit specified in Test Suite.' )","published":true,"deleted":false,"likes_count":2,"comments_count":16,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":13,"test_suite_updated_at":"2019-07-02T13:23:18.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2017-10-12T23:17:24.000Z","updated_at":"2026-04-02T20:05:58.000Z","published_at":"2017-10-15T06:52:40.000Z","restored_at":"2017-10-25T07:03:11.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\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\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple\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://en.wikipedia.org/wiki/Caesar_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCaesar cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (a type 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://en.wikipedia.org/wiki/Substitution_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esubstitution cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e), an example of which is the\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://en.wikipedia.org/wiki/ROT13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eROT13 cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (discussed in\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/78-implement-a-rot13-cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Challenge Problem 78\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e). As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation, numbers, accented letters) are unchanged. Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and will vary\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ebetween\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (not within) batches — also, here you need to decode, not encode.\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\u003eThese latest activities that you are investigating have been nicknamed 'Operation Xiangliu' by your own organisation. A few decoding options are at your organisation's disposal:\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTest the candidate decodings against all words in a large dictionary — this could work, but it is very slow.\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTest the candidate decodings for the appearance of a name or phrase that is certain to appear regularly (e.g.\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/44351\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"Operation Phoenix\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e) — unfortunately as yet there is not enough knowledge of the activities to be sure of a suitable name or phrase to use.\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTest the candidate decodings against all words in a short list comprising, say, the hundred most frequently used English 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\u003eThe\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ethird option\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e will be faster than the first option, and more reliable than the second option, so this is the approach you will be taking.\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 have been careful to avoid using 'lemmatised' lists (which contain e.g. the verb \\\"to be\\\", rather than the various inflected forms such as \\\"am\\\", \\\"is\\\", \\\"are\\\") like those based on the\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://web.archive.org/web/20111226085859/http://oxforddictionaries.com/words/the-oec-facts-about-the-language\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOEC\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e or\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.wordfrequency.info/free.asp?s=y\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCOCA\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, and after setting aside\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://world-english.org/english500.htm\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eanother list\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e you finally choose the\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://ucrel.lancs.ac.uk/bncfreq/samples/120.pdf\\\"\u003e\u003cw:r\u003e\u003cw:t\u003elist based on the BNC\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e as the most reliable, and will use the first 100 words on that list. This list will be available for you to access as an input variable,\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:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ebncWordlist\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, to your function. Note: (i) some entries on the list are morphemes (e.g. \\\" n't \\\" and \\\" 's \\\") rather than words; (ii) some entries appear more than once (representing different grammatical word classes). Of course, in the original messages any capitalisation might be used.\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 have been instructed that your 'certitude' (degree of confidence) in the decoding must be reported for each batch, and shall depend proportionally upon the sum of the characters for the words/morphemes in the decoded message that match words/morphemes in\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:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ebncWordlist\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Being able to match words/morphemes accounting for three-tenths of the characters (excluding spaces) shall correspond to 100% certitude; matching three-twentieths would be 50% certitude, and so on. Certitude shall be reported as a percentage, rounded\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eup\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to the nearest integer, not greater than 100. You need to maximise your certitude for each batch by appropriate choice of the shifting parameter. If there are multiple shifts of equal certitude, report both options on different rows (arranged in order of ascending shift parameter).\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\u003eYour task is to crack the codes and report back in a\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://au.mathworks.com/help/matlab/ref/struct.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estructure array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e: (1) the shifting parameter that had been used in the encoding [as\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://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e] (usually scalar, but may be column vector); (2) the decoded messages [as a\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://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ecell array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (containing\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://au.mathworks.com/help/matlab/ref/char.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003echaracter arrays\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e)] (usually an array with a single row, but occasionally with multiple rows); (3) your 'certitude' in the decoding [as\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://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e] (always scalar). The name of the structure array shall be\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:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, with respective fields\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:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eshift\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\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emessage\u003c/w:t\u003e\u003c/w:r\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:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecertitude\u003c/w:t\u003e\u003c/w:r\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eEXAMPLE 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the batch contained two encoded messages —\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Vomftt qvstvfe, pqfo op eppst.\\\"\u003c/w:t\u003e\u003c/w:r\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:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Ffmt dbo ljmm, opu pomz xpvoe.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied. In that case A→B, B→C, ..., Y→Z, and Z→A; similarly, a→b, b→c, ..., y→z, and z→a. Thus the original messages would have been: \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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Unless pursued, open no doors.\\\"\u003c/w:t\u003e\u003c/w:r\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:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Eels can kill, not only wound.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e . Twelve of the 51 characters have been matched: \\\"no\\\", \\\"can\\\", \\\"not\\\", and \\\"only\\\".\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 correct answer would therefore comprise:\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[s.shift = uint8(1)  \\ns.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'}\\ns.certitude = uint8(79)]]\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eEXAMPLE 2\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\u003eSuppose the batch contained one encoded message —\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Oa oqvvq'u cnycau dggp: \\\"Ctu itcvkc ctvku\\\".\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (provided as a character array within a cell array) — and a (right-shifting) ROT2 cipher had been applied. In that case A→C, B→D, ..., Y→A, and Z→B; similarly, a→c, b→d, ..., y→a, and z→b. Thus the original message would have been: \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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"My motto's always been: \\\"Ars gratia artis\\\".\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e . Eight of the 37 characters have been matched: \\\"My\\\", \\\" 's \\\", and \\\"been\\\". Note carefully that: \\\" 's \\\" should only be matched once; \\\"to\\\" (in motto), \\\"be\\\" (in been), \\\"at\\\" (in gratia), \\\"is\\\" (in artis) and \\\"a\\\" (passim) should\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003enot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e be matched at all; and \\\" ' \\\" will only ever be used as an apostrophe (never as a quotation mark).\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 correct answer would therefore comprise:\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[s.shift = uint8(2)  \\ns.message = {'My motto''s always been: \\\"Ars gratia artis\\\".'}\\ns.certitude = uint8(73)]]\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\u003eIf the batch of messages cannot be decoded when following the above assumptions, then return the original encoded message(s) unchanged, with a shift of zero and a certitude of zero.\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:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\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\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \\\"too slow\\\".\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\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\u003ePrevious problem: \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/44356\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Orthos\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: TBA.\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":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":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":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":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":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":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\"}]}"},{"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":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":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":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":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":213,"title":"Create a dictionary","description":"The goal is to write a function that returns a dictionary from a list of words or phrases and their definitions. Here is an example:\r\n\r\n  \u003e\u003e words = {'do', 're', 'mi'};\r\n  \u003e\u003e definitions = {'a deer', 'a drop of golden sun', 'a name I call myself'};\r\n  \u003e\u003e dictionary = createDictionary(words, definitions);\r\n  \u003e\u003e dictionary('mi')\r\n  \r\n  ans =\r\n  \r\n  a name I call myself\r\n\r\nThe first and second arguments will always be cell strings but can contain any characters. The output must be a function handle.","description_html":"\u003cp\u003eThe goal is to write a function that returns a dictionary from a list of words or phrases and their definitions. Here is an example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u003e\u003e words = {'do', 're', 'mi'};\r\n\u003e\u003e definitions = {'a deer', 'a drop of golden sun', 'a name I call myself'};\r\n\u003e\u003e dictionary = createDictionary(words, definitions);\r\n\u003e\u003e dictionary('mi')\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eans =\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003ea name I call myself\r\n\u003c/pre\u003e\u003cp\u003eThe first and second arguments will always be cell strings but can contain any characters. The output must be a function handle.\u003c/p\u003e","function_template":"function d = createDictionary(words, definitions)\r\n  d = @(word) 'This is a definition.';\r\nend","test_suite":"%% Simple test case\r\nwords = {'uno', 'deux', 'tre'};\r\ndefinitions = {'Spanish', 'French', 'Italian'};\r\nd = createDictionary(words, definitions);\r\norder = [2 1 3];\r\nassert(isequal(definitions(order), cellfun(d, words(order), 'UniformOutput', false)))\r\n\r\n%% Nearly identical words\r\nwords = {'CamelCase', 'camelCase', 'camel case', 'CAMELCASE'};\r\ndefinitions = {'More properly MixedCase', 'Also known as nerdCaps', ...\r\n     'A dromedary valise', 'Why are you shouting?'};\r\nd = createDictionary(words, definitions);\r\norder = [4 2 1 3];\r\nassert(isequal(definitions(order), cellfun(d, words(order), 'UniformOutput', false)))\r\n\r\n%% Words with punctuation\r\nwords = {'J.R.R. Tolkien', 'George R.R. Martin', '#!', 'Ke$ha'};\r\ndefinitions = {'LoTR', 'GoT', 'Shebang', 'Don''t ask'};\r\nd = createDictionary(words, definitions);\r\norder = [4 1 3 2];\r\nassert(isequal(definitions(order), cellfun(d, words(order), 'UniformOutput', false)))\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":321,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":81,"test_suite_updated_at":"2012-02-01T15:40:34.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2012-02-01T15:40:34.000Z","updated_at":"2026-04-02T20:23:25.000Z","published_at":"2012-02-01T15:40: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\u003eThe goal is to write a function that returns a dictionary from a list of words or phrases and their definitions. Here is an example:\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[\u003e\u003e words = {'do', 're', 'mi'};\\n\u003e\u003e definitions = {'a deer', 'a drop of golden sun', 'a name I call myself'};\\n\u003e\u003e dictionary = createDictionary(words, definitions);\\n\u003e\u003e dictionary('mi')\\n\\nans =\\n\\na name I call myself]]\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 and second arguments will always be cell strings but can contain any characters. The output must be a function handle.\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":154,"title":"Reverse Boggle","description":"Description\r\nIn the classic Parker Brothers game Boggle, players find words from a 4x4 game board of letters. This exercise is to make sure that a particular solution to a boggle board is actually available on the board.\r\nThe program does not need to check to make sure if the input word is a valid english word. Furthermore, all inputs will be in all uppercase, so the user does not need to check/convert for case differences. The game board will always be 4x4.\r\nNote: This does not perfectly align with the rules of Boggle. Specifically, all solutions in the original game must be 3 or more letters, which this problem is not asking to account for, and the atomic \"Qu\" is present (which I have avoided in the test suite).\r\nHappy MATLABing!\r\nExample\r\n    x = ['TIPE'\r\n         'YECV'\r\n         'LSRA'\r\n         'WOTU'];\r\n    y = 'RACIEST';\r\n    TF = true;","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: 387.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 193.8px; transform-origin: 407px 193.8px; vertical-align: baseline; \"\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: 40.5px 8px; transform-origin: 40.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eDescription\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: 112px 8px; transform-origin: 112px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIn the classic Parker Brothers game\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 = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eBoggle\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: 247px 8px; transform-origin: 247px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, players find words from a 4x4 game board of letters. This exercise is to make sure that a particular solution to a boggle board is actually available on the board.\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: 41px 8px; transform-origin: 41px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe program\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\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: 27.5px 8px; transform-origin: 27.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003edoes not\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: 311px 8px; transform-origin: 311px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e need to check to make sure if the input word is a valid english word. Furthermore, all inputs will be in all uppercase, so the user does not need to check/convert for case differences. The game board will always be 4x4.\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: 370px 8px; transform-origin: 370px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNote: This does not perfectly align with the rules of Boggle. Specifically, all solutions in the original game must be 3 or more letters, which this problem is not asking to account for, and the atomic \"Qu\" is present (which I have avoided in the test suite).\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: 61px 8px; transform-origin: 61px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHappy MATLABing!\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: 29.5px 8px; transform-origin: 29.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExample\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 122.6px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 61.3px; transform-origin: 404px 61.3px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; tab-size: 4; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 36px 8.5px; transform-origin: 36px 8.5px; \"\u003e    x = [\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 24px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 24px 8.5px; \"\u003e'TIPE'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; tab-size: 4; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 36px 8.5px; transform-origin: 36px 8.5px; \"\u003e         \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 24px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 24px 8.5px; \"\u003e'YECV'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; tab-size: 4; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 36px 8.5px; transform-origin: 36px 8.5px; \"\u003e         \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 24px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 24px 8.5px; \"\u003e'LSRA'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 68px 8.5px; tab-size: 4; transform-origin: 68px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 36px 8.5px; transform-origin: 36px 8.5px; \"\u003e         \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 24px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 24px 8.5px; \"\u003e'WOTU'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 8px 8.5px; transform-origin: 8px 8.5px; \"\u003e];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 72px 8.5px; tab-size: 4; transform-origin: 72px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e    y = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 36px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003e'RACIEST'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; tab-size: 4; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e    TF = true;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tf = boggle_checker(x,y)\r\n  tf = true;\r\nend","test_suite":"%%\r\nx = ['TIPE'\r\n     'YECV'\r\n     'LSRA'\r\n     'WOTU'];\r\ny = 'RACIEST';\r\nassert(isequal(boggle_checker(x,y),true))\r\n\r\n%%\r\nx = ['TIPE'\r\n     'YECV'\r\n     'LSRA'\r\n     'WOTU'];\r\ny = 'RACIESTS';\r\nassert(isequal(boggle_checker(x,y),false))\r\n\r\n%%\r\nx = ['TIPE'\r\n     'YECV'\r\n     'LSRA'\r\n     'WOTU'];\r\ny = 'RACIESTW';\r\nassert(isequal(boggle_checker(x,y),false))\r\n\r\n%%\r\nx = ['TIPE'\r\n     'YECV'\r\n     'LSRA'\r\n     'WOTU'];\r\ny = 'AUTOLYTIC';\r\nassert(isequal(boggle_checker(x,y),true))\r\n\r\n%%\r\nx = ['TIPE'\r\n     'YECV'\r\n     'LSRA'\r\n     'WOTU'];\r\ny = 'RESTAR';\r\nassert(isequal(boggle_checker(x,y),false))\r\n\r\n%%\r\nx = ['OCEW'\r\n     'LRIR'\r\n     'GYSI'\r\n     'KREM'];\r\ny = 'SIRI';\r\nassert(isequal(boggle_checker(x,y),true))\r\n\r\n%%\r\nx = ['OCEW'\r\n     'LRIR'\r\n     'GYSI'\r\n     'KREM'];\r\ny = 'SIRIM';\r\nassert(isequal(boggle_checker(x,y),true))\r\n\r\n%%\r\nx = ['OCEW'\r\n     'LRIR'\r\n     'GYSI'\r\n     'KREM'];\r\ny = 'GLORY';\r\nassert(isequal(boggle_checker(x,y),true))\r\n\r\n%%\r\nx = ['OCEW'\r\n     'LRIR'\r\n     'GYSI'\r\n     'KREM'];\r\ny = 'ROME';\r\nassert(isequal(boggle_checker(x,y),false))","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":134,"edited_by":223089,"edited_at":"2023-02-02T11:43:47.000Z","deleted_by":null,"deleted_at":null,"solvers_count":60,"test_suite_updated_at":"2023-02-02T11:43:47.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2012-01-28T22:27:00.000Z","updated_at":"2026-04-02T08:30:49.000Z","published_at":"2012-02-01T01:02:17.000Z","restored_at":null,"restored_by":null,"spam":null,"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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eDescription\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\u003eIn the classic Parker Brothers game\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=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eBoggle\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, players find words from a 4x4 game board of letters. This exercise is to make sure that a particular solution to a boggle board is actually available on the 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe program\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edoes not\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e need to check to make sure if the input word is a valid english word. Furthermore, all inputs will be in all uppercase, so the user does not need to check/convert for case differences. The game board will always be 4x4.\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\u003eNote: This does not perfectly align with the rules of Boggle. Specifically, all solutions in the original game must be 3 or more letters, which this problem is not asking to account for, and the atomic \\\"Qu\\\" is present (which I have avoided in the test suite).\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\u003eHappy MATLABing!\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    x = ['TIPE'\\n         'YECV'\\n         'LSRA'\\n         'WOTU'];\\n    y = 'RACIEST';\\n    TF = true;]]\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\"}]}"}],"no_progress_badge":{"id":53,"name":"Unknown","symbol":"unknown","description":"Partially completed groups","description_html":null,"image_location":"/images/responsive/supporting/matlabcentral/cody/badges/problem_groups_unknown_2.png","bonus":null,"players_count":0,"active":false,"created_by":null,"updated_by":null,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"created_at":"2018-01-10T23:20:29.000Z","updated_at":"2018-01-10T23:20:29.000Z","community_badge_id":null,"award_multiples":false}}