Cody

# Problem 1182. Hangman (easy)

Solution 958399

Submitted on 3 Sep 2016 by paolo77
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

letters = 2 letters = 2 3 letters = 2 3 0 letters = 2 3 0 2 letters = 2 3 0 2 2 letters = 2 3 0 2 2 0 letters = 2 3 0 2 2 0 1 letters = 2 3 0 2 2 0 1 0 letters = 2 3 0 2 2 0 1 0 0 letters = 2 3 0 2 2 0 1 0 0 0 letters = 2 3 0 2 2 0 1 0 0 0 0 letters = 2 3 0 2 2 0 1 0 0 0 0 0 letters = 2 3 0 2 2 0 1 0 0 0 0 0 0 letters = 2 3 0 2 2 0 1 0 0 0 0 0 0 0 letters = 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 letters = 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 0 letters = Columns 1 through 16 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 0 Column 17 0 letters = Columns 1 through 16 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 0 Columns 17 through 18 0 0 letters = Columns 1 through 16 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 0 Columns 17 through 19 0 0 0 letters = Columns 1 through 16 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 0 Columns 17 through 20 0 0 0 0 letters = Columns 1 through 16 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 0 Columns 17 through 21 0 0 0 0 0 letters = Columns 1 through 16 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 0 Columns 17 through 22 0 0 0 0 0 0 letters = Columns 1 through 16 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 0 Columns 17 through 23 0 0 0 0 0 0 0 letters = Columns 1 through 16 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 0 Columns 17 through 24 0 0 0 0 0 0 0 0 letters = Columns 1 through 16 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 0 Columns 17 through 25 0 0 0 0 0 0 0 0 0 letters = Columns 1 through 16 2 3 0 2 2 0 1 0 0 0 0 0 0 0 0 0 Columns 17 through 26 0 0 0 0 0 0 0 0 0 0

2   Pass
words={'BUZZ','COZY','DOZE','FUZZ','GAZE','HAZE','JAZZ','LAZY','SIZE','ZERO','ZONE'}; assert(isequal(hangman(words),'Z'));

letters = 4 letters = 4 1 letters = 4 1 1 letters = 4 1 1 1 letters = 4 1 1 1 6 letters = 4 1 1 1 6 1 letters = 4 1 1 1 6 1 1 letters = 4 1 1 1 6 1 1 1 letters = 4 1 1 1 6 1 1 1 1 letters = 4 1 1 1 6 1 1 1 1 1 letters = 4 1 1 1 6 1 1 1 1 1 0 letters = 4 1 1 1 6 1 1 1 1 1 0 1 letters = 4 1 1 1 6 1 1 1 1 1 0 1 0 letters = 4 1 1 1 6 1 1 1 1 1 0 1 0 1 letters = 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 letters = 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 0 letters = Columns 1 through 16 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 0 Column 17 0 letters = Columns 1 through 16 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 0 Columns 17 through 18 0 1 letters = Columns 1 through 16 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 0 Columns 17 through 19 0 1 1 letters = Columns 1 through 16 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 0 Columns 17 through 20 0 1 1 0 letters = Columns 1 through 16 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 0 Columns 17 through 21 0 1 1 0 2 letters = Columns 1 through 16 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 0 Columns 17 through 22 0 1 1 0 2 0 letters = Columns 1 through 16 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 0 Columns 17 through 23 0 1 1 0 2 0 0 letters = Columns 1 through 16 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 0 Columns 17 through 24 0 1 1 0 2 0 0 0 letters = Columns 1 through 16 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 0 Columns 17 through 25 0 1 1 0 2 0 0 0 2 letters = Columns 1 through 16 4 1 1 1 6 1 1 1 1 1 0 1 0 1 4 0 Columns 17 through 26 0 1 1 0 2 0 0 0 2 11

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'))));

letters = 10 letters = 10 7 letters = 10 7 12 letters = 10 7 12 12 letters = 10 7 12 12 14 letters = 10 7 12 12 14 10 letters = 10 7 12 12 14 10 18 letters = 10 7 12 12 14 10 18 7 letters = 10 7 12 12 14 10 18 7 8 letters = 10 7 12 12 14 10 18 7 8 10 letters = 10 7 12 12 14 10 18 7 8 10 8 letters = 10 7 12 12 14 10 18 7 8 10 8 12 letters = 10 7 12 12 14 10 18 7 8 10 8 12 13 letters = 10 7 12 12 14 10 18 7 8 10 8 12 13 11 letters = 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 letters = 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 8 letters = Columns 1 through 16 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 8 Column 17 11 letters = Columns 1 through 16 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 8 Columns 17 through 18 11 10 letters = Columns 1 through 16 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 8 Columns 17 through 19 11 10 10 letters = Columns 1 through 16 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 8 Columns 17 through 20 11 10 10 11 letters = Columns 1 through 16 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 8 Columns 17 through 21 11 10 10 11 14 letters = Columns 1 through 16 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 8 Columns 17 through 22 11 10 10 11 14 10 letters = Columns 1 through 16 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 8 Columns 17 through 23 11 10 10 11 14 10 6 letters = Columns 1 through 16 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 8 Columns 17 through 24 11 10 10 11 14 10 6 15 letters = Columns 1 through 16 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 8 Columns 17 through 25 11 10 10 11 14 10 6 15 16 letters = Columns 1 through 16 10 7 12 12 14 10 18 7 8 10 8 12 13 11 9 8 Columns 17 through 26 11 10 10 11 14 10 6 15 16 8

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'))));

letters = 24 letters = 24 31 letters = 24 31 34 letters = 24 31 34 32 letters = 24 31 34 32 36 letters = 24 31 34 32 36 26 letters = 24 31 34 32 36 26 34 letters = 24 31 34 32 36 26 34 24 letters = 24 31 34 32 36 26 34 24 25 letters = 24 31 34 32 36 26 34 24 25 21 letters = 24 31 34 32 36 26 34 24 25 21 27 letters = 24 31 34 32 36 26 34 24 25 21 27 36 letters = 24 31 34 32 36 26 34 24 25 21 27 36 33 letters = 24 31 34 32 36 26 34 24 25 21 27 36 33 32 letters = 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 letters = 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 31 letters = Columns 1 through 16 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 31 Column 17 32 letters = Columns 1 through 16 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 31 Columns 17 through 18 32 32 letters = Columns 1 through 16 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 31 Columns 17 through 19 32 32 31 letters = Columns 1 through 16 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 31 Columns 17 through 20 32 32 31 32 letters = Columns 1 through 16 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 31 Columns 17 through 21 32 32 31 32 29 letters = Columns 1 through 16 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 31 Columns 17 through 22 32 32 31 32 29 31 letters = Columns 1 through 16 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 31 Columns 17 through 23 32 32 31 32 29 31 22 letters = Columns 1 through 16 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 31 Columns 17 through 24 32 32 31 32 29 31 22 28 letters = Columns 1 through 16 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 31 Columns 17 through 25 32 32 31 32 29 31 22 28 30 letters = Columns 1 through 16 24 31 34 32 36 26 34 24 25 21 27 36 33 32 27 31 Columns 17 through 26 32 32 31 32 29 31 22 28 30 24

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'))));

letters = 75 letters = 75 89 letters = 75 89 97 letters = 75 89 97 94 letters = 75 89 97 94 93 letters = 75 89 97 94 93 84 letters = 75 89 97 94 93 84 92 letters = 75 89 97 94 93 84 92 74 letters = 75 89 97 94 93 84 92 74 85 letters = 75 89 97 94 93 84 92 74 85 80 letters = 75 89 97 94 93 84 92 74 85 80 103 letters = 75 89 97 94 93 84 92 74 85 80 103 104 letters = 75 89 97 94 93 84 92 74 85 80 103 104 66 letters = 75 89 97 94 93 84 92 74 85 80 103 104 66 95 letters = 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 letters = 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 97 letters = Columns 1 through 16 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 97 Column 17 85 letters = Columns 1 through 16 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 97 Columns 17 through 18 85 87 letters = Columns 1 through 16 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 97 Columns 17 through 19 85 87 99 letters = Columns 1 through 16 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 97 Columns 17 through 20 85 87 99 97 letters = Columns 1 through 16 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 97 Columns 17 through 21 85 87 99 97 86 letters = Columns 1 through 16 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 97 Columns 17 through 22 85 87 99 97 86 93 letters = Columns 1 through 16 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 97 Columns 17 through 23 85 87 99 97 86 93 75 letters = Columns 1 through 16 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 97 Columns 17 through 24 85 87 99 97 86 93 75 89 letters = Columns 1 through 16 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 97 Columns 17 through 25 85 87 99 97 86 93 75 89 85 letters = Columns 1 through 16 75 89 97 94 93 84 92 74 85 80 103 104 66 95 97 97 Columns 17 through 26 85 87 99 97 86 93 75 89 85 87