Cody

Solution 663465

Submitted on 30 Apr 2015 by Guillaume
  • Size: 39
  • This is the leading solution.
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'}; max_score_corr = 12; max_word_corr = {'atheism','hamlets'}; [max_score,max_word] = scrabble_scores_10(words,existing_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))

2   Pass
%% 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'}; max_score_corr = 8; max_word_corr = {'lentoid','tendril','trindle'}; [max_score,max_word] = scrabble_scores_10(words,existing_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))

3   Pass
%% existing_letter = 'n'; %the word must contain 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 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 = 14; max_word_corr = {'axmen'}; [max_score,max_word] = scrabble_scores_10(words,existing_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))

4   Pass
%% existing_letter = 'z'; %the word must contain 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 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_10(words,existing_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 existing_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 = 12; max_word_corr = {'atheism','hamlets'}; case 2 existing_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 = {'lentoid','tendril','trindle'}; case 3 existing_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 = 14; max_word_corr = {'axmen'}; case 4 existing_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_10(words,existing_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))

6   Pass
%% anti-cheating test case ind = randi(4); switch ind case 1 existing_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 = 12; max_word_corr = {'atheism','hamlets'}; case 2 existing_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 = {'lentoid','tendril','trindle'}; case 3 existing_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 = 14; max_word_corr = {'axmen'}; case 4 existing_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_10(words,existing_letter); assert(isequal(max_score,max_score_corr)) assert(isequal(max_word,max_word_corr))