Cody

# Problem 3084. Scrabble Scores - 11

Solution 774027

Submitted on 9 Nov 2015 by Alfonso Nieto-Castanon
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
%% existing_letter = 's'; %the word must contain 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 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'}; mult = ' 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) max_score_corr = 39; max_word_corr = {'hamlets'}; [max_score,max_word] = scrabble_scores_11(words,mult,existing_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))

2   Pass
%% ind = randi(4); existing_letter = 's'; %the word must contain 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 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'}; switch ind case 1 mult = ' 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) max_score_corr = 39; max_word_corr = {'hamlets'}; case 2 mult = '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) max_score_corr = 32; max_word_corr = {'atheism'}; case 3 mult = '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) max_score_corr = 153; max_word_corr = {'halest'}; case 4 mult = '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) max_score_corr = 60; max_word_corr = {'heliast'}; end [max_score,max_word] = scrabble_scores_11(words,mult,existing_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))

3   Pass
%% ind = randi(4); existing_letter = 't'; %the word must contain 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 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'}; switch ind case 1 mult = ' 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) max_score_corr = 27; max_word_corr = {'tendril','trindle'}; case 2 mult = '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) max_score_corr = 18; max_word_corr = {'retinol','tendril','trindle'}; case 3 mult = '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) max_score_corr = 81; max_word_corr = {'retinol'}; case 4 mult = '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) max_score_corr = 90; max_word_corr = {'lentoid'}; end [max_score,max_word] = scrabble_scores_11(words,mult,existing_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))

4   Pass