Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 187506

Submitted on 7 Jan 2013 by José Ramón Menzinger

Correct

44Size
Leading solution size is 19.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
words={'AAA','BED','BEG','BAD'};
assert(isequal(hangman(words),'B'));
ans =
B
2
Pass
 
%%
words={'BUZZ','COZY','DOZE','FUZZ','GAZE','HAZE','JAZZ','LAZY','SIZE','ZERO','ZONE'};
assert(isequal(hangman(words),'Z'));
ans =
Z
3
Pass
 
%%
rng default;
words=unique(char('A'+randi(26,[100,3])-1),'rows');
assert(isequal(sum(any(words==hangman(cellstr(words)'),2)),max(arrayfun(@(x)sum(any(words==x,2)),'A':'Z'))));
ans =
G
4
Pass
 
%%
rng default;
words=unique(char('A'+randi(26,[200,4])-1),'rows');
assert(isequal(sum(any(words==hangman(cellstr(words)'),2)),max(arrayfun(@(x)sum(any(words==x,2)),'A':'Z'))));
ans =
E
5
Pass
 
%%
rng default;
words=unique(char('A'+randi(26,[500,5])-1),'rows');
assert(isequal(sum(any(words==hangman(cellstr(words)'),2)),max(arrayfun(@(x)sum(any(words==x,2)),'A':'Z'))));
ans =
L