Cody

# Problem 3062. Scrabble Scores - 9

Solution 719674

Submitted on 22 Aug 2015 by Jean-Marie Sainthillier
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% first_letter = 's'; %the word must start with this letter, which is in an already played word tray_letters = 'aethilm'; %your tray letters; informational (not part of the problem) %all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix) words = {'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'}; max_score_corr = 10; max_word_corr = {'shame','smith'}; [max_score,max_word] = scrabble_scores_9(words,first_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))

2   Pass
%% first_letter = 't'; %the word must start with this letter, which is in an already played word tray_letters = 'eodnirl'; %your tray letters; informational (not part of the problem) %all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix) words = {'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'}; max_score_corr = 8; max_word_corr = {'tendril','trindle'}; [max_score,max_word] = scrabble_scores_9(words,first_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))

3   Pass
%% first_letter = 'n'; %the word must start with this letter, which is in an already played word tray_letters = 'dmvxeao'; %your tray letters; informational (not part of the problem) %all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix) words = {'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'}; max_score_corr = 8; max_word_corr = {'named','nomad','novae'}; [max_score,max_word] = scrabble_scores_9(words,first_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))

4   Pass
%% first_letter = 'z'; %the word must start with this letter, which is in an already played word tray_letters = 'aehcmdi'; %your tray letters; informational (not part of the problem) %all possible words, including the first letter with your tray letters (though the first letter has been thrown into the mix) words = {'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'}; max_score_corr = 19; max_word_corr = {'zaideh'}; [max_score,max_word] = scrabble_scores_9(words,first_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))

5   Pass
%% anti-cheating test case ind = randi(4); switch ind case 1 first_letter = 's'; words = {'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'}; max_score_corr = 10; max_word_corr = {'shame','smith'}; case 2 first_letter = 't'; words = {'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'}; max_score_corr = 8; max_word_corr = {'tendril','trindle'}; case 3 first_letter = 'n'; words = {'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'}; max_score_corr = 8; max_word_corr = {'named','nomad','novae'}; case 4 first_letter = 'z'; words = {'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'}; max_score_corr = 19; max_word_corr = {'zaideh'}; end [max_score,max_word] = scrabble_scores_9(words,first_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))