Cody

Solution 1667364

Submitted on 7 Nov 2018
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   Fail
assignin('caller','score',300); a.words0={'BUZZ','COZY','DOZE','FUZZ','GAZE','HAZE','JAZZ','LAZY','SIZE','ZERO','ZONE'}; a.e=0; for n=randperm(numel(a.words0)) a.i=n; a.words=a.words0; a.n=n; for m=1:100, a.m=m; assignin('caller','a',a); letter=hangman(a.words); letter=char(letter(1)); a=evalin('caller','a'); m=a.m; fprintf('Target word %s; Step %d; Word list %s; Guess %c\n',a.words{a.i},a.m,sprintf('%s ',a.words{:}),letter); matchedletters=a.words{a.i}==letter; if ~any(matchedletters), a.e=a.e+1; end matchedwords=find(cellfun(@(x)isequal(matchedletters,x==letter),a.words)); a.i=find(matchedwords==a.i); a.words=regexprep(a.words(matchedwords),letter,''); nonemptywords=find(cellfun('length',a.words)>0); a.i=find(nonemptywords==a.i); if isempty(a.i), break; end end if ~isempty(a.i), error(sprintf('algorithm did not guess word after 100 steps. Last message: Target word %s; Step %d; Word list %s; Guessed letter %c\n',a.words{a.i},a.m,sprintf('%s ',a.words{:}),letter)); end n=a.n; end a.e=a.e/numel(a.words0); fprintf('Average number of errors per word %f\n',a.e); assert(a.e<5); assignin('caller','score',evalin('caller','score')-100+round(a.e/5*100));

Target word GAZE; Step 1; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY SIZE ZERO ZONE ; Guess S Target word GAZE; Step 2; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 3; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 4; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 5; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 6; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 7; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 8; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 9; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 10; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 11; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 12; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 13; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 14; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 15; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 16; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 17; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 18; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 19; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 20; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 21; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 22; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 23; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 24; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 25; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 26; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 27; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 28; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 29; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 30; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 31; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 32; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 33; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 34; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 35; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 36; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 37; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 38; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 39; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 40; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 41; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 42; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 43; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 44; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 45; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 46; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 47; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 48; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 49; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 50; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 51; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 52; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 53; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 54; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 55; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 56; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 57; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 58; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 59; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 60; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 61; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 62; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 63; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 64; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 65; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 66; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 67; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 68; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 69; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 70; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 71; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 72; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 73; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 74; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 75; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 76; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 77; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 78; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 79; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 80; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 81; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 82; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 83; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 84; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 85; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 86; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 87; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 88; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 89; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 90; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 91; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 92; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 93; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 94; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 95; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 96; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 97; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 98; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 99; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S Target word GAZE; Step 100; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guess S

algorithm did not guess word after 100 steps. Last message: Target word GAZE; Step 100; Word list BUZZ COZY DOZE FUZZ GAZE HAZE JAZZ LAZY ZERO ZONE ; Guessed letter S

2   Fail
rng default; a.words0=cellstr(unique(char('A'+ceil(26*rand([200,3]).^2)-1),'rows'))'; a.e=0; for n=randperm(numel(a.words0)) a.i=n; a.words=a.words0; a.n=n; for m=1:100, a.m=m; assignin('caller','a',a); letter=hangman(a.words); letter=char(letter(1)); a=evalin('caller','a'); m=a.m; matchedletters=a.words{a.i}==letter; if ~any(matchedletters), a.e=a.e+1; end matchedwords=find(cellfun(@(x)isequal(matchedletters,x==letter),a.words)); a.i=find(matchedwords==a.i); a.words=regexprep(a.words(matchedwords),letter,''); nonemptywords=find(cellfun('length',a.words)>0); a.i=find(nonemptywords==a.i); if isempty(a.i), break; end end if ~isempty(a.i), error(sprintf('algorithm did not guess word after 100 steps. Last message: Target word %s; Step %d; Word list %s; Guessed letter %c\n',a.words{a.i},a.m,sprintf('%s ',a.words{:}),letter)); end n=a.n; end a.e=a.e/numel(a.words0); fprintf('Average number of errors per word %f\n',a.e); assert(a.e<5); assignin('caller','score',evalin('caller','score')-100+round(a.e/5*100));

algorithm did not guess word after 100 steps. Last message: Target word AAP; Step 100; Word list AAA AAB AAC AAE AAF AAG AAH AAI AAP AAT AAY ABA ABB ABE ABH ABL ABX ACH ADE AEL AEM AEO AET AGA AGB AGF AGK AHC AHW AME AMO ANX AQH ARD ARJ ATB AWD AWE AWM AXF AZE BCH BHB BJK BKQ BLA BLP BNV BPC BRW BUM BUN BUU BYH BYV BZA BZD BZH CAC CAG CAT CCL CCU CFJ CJN CTK DAH DAI DAK DBB DDX DEQ DIE DNO DQJ DVI DZB EBA EBH ECM ECO EEY ELD FAA FAB FBK FGL FIZ FJL FLH GBR GCG GEA GKP GLA GMF GNP GOB GRA GVF HAB HBG HCA HEB HFX HGO HHA HUP IAD IBL IDF IGK IIF JAA JME KDM KDR KDT KIA KJP KWA LBF LCP LHF LRK LVA MCC MHA MJG MNF MQA MRB NBA NBJ OAA OAK OFD OFF OJB OJI OTA OYC PAD PAR PIQ PQL PQP PUA QAA QBA QKA QMH RAA RAC RAK RAL RFZ RGA RKE ROL TDE TEP UAD VAC VAE VDA VEA VHF VKN VLM VVB WAB WGL WNA WVH XBJ XEJ XEM XFE XFQ XHM XKA XLC XZO YCL YDF YIC ZRA ; Guessed letter S

3   Fail
rng default; a.words0=cellstr(unique(char('A'+ceil(26*rand([200,4]).^2)-1),'rows'))'; a.e=0; for n=randperm(numel(a.words0)) a.i=n; a.words=a.words0; a.n=n; for m=1:100, a.m=m; assignin('caller','a',a); letter=hangman(a.words); letter=char(letter(1)); a=evalin('caller','a'); m=a.m; matchedletters=a.words{a.i}==letter; if ~any(matchedletters), a.e=a.e+1; end matchedwords=find(cellfun(@(x)isequal(matchedletters,x==letter),a.words)); a.i=find(matchedwords==a.i); a.words=regexprep(a.words(matchedwords),letter,''); nonemptywords=find(cellfun('length',a.words)>0); a.i=find(nonemptywords==a.i); if isempty(a.i), break; end end if ~isempty(a.i), error(sprintf('algorithm did not guess word after 100 steps. Last message: Target word %s; Step %d; Word list %s; Guessed letter %c\n',a.words{a.i},a.m,sprintf('%s ',a.words{:}),letter)); end n=a.n; end a.e=a.e/numel(a.words0); fprintf('Average number of errors per word %f\n',a.e); assert(a.e<5); assignin('caller','score',evalin('caller','score')-100+round(a.e/5*100));

algorithm did not guess word after 100 steps. Last message: Target word DAIB; Step 100; Word list AAAR AABE AABP AACA AAEA AAEC AAFA AAGA AAHO AAII AAPV AATI AAYB ABAA ABBA ABEK ABHJ ABLA ABXI ACHB ADEH AELL AEMA AEOA AETZ AGAB AGBA AGFC AGFJ AGKH AHCA AHWB AMEA AMOK ANXI AQHC ARDA ARJW ATBC AWDD AWEI AWMR AXFB AZEC BCHA BHBU BJKW BKQO BLAL BLPA BNVB BPCA BRWL BUMI BUNG BUUA BYHM BYVA BZAF BZDC BZHO CACC CAGA CATD CCLG CCUI CJNT CTKU DAHN DAIB DAKO DBBK DDXA DEQG DIEA DNOJ DQJA DVIK DZBG EBAF EBAQ EBHG ECMV ECOF EEYV ELDP FAAA FABH FBKN FGLG FIZC FJLO FLHZ GBRF GCGA GEAA GKPH GLAA GMFC GNPA GOBA GRAU HABF HBGM HCAI HEBF HFXW HGOA HHAZ HUPW IADC IBLC IDFH IGKT IIFE JAAA JMEW KDMI KDRO KDTP KIAA KJPN KWAA LBFU LCPO LHFA LRKC LVAA MCCT MHAA MJGP MNFU MQAT MRBP NBAN NBJA OAAA OAKA OFDB OFFL OJBQ OJIE OTAG OYCK PADC PARK PIQA PQLA PQPH PUAG QAAX QBAI QKAF RAAQ RACA RAKC RALA RFZE RGAA ROLA TDEJ TEPA UADB VACV VAEA VDAI VEAA VHFM VKNZ VLMZ VVBZ WABL WGLC WNAA WVHH XBJB XFEH XFQA XHMC XKAA XLCM XZOR YCLZ YDFD YICT ZRAP ; Guessed letter S