Cody

Solution 1495012

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