Cody

Solution 2254738

Submitted on 4 May 2020
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
s1 = 'The all day meetings will continue until we learn why productivity is so low'; s2_correct = 'The all day will we learn why is so low'; assert(isequal(just_short_words(s1),s2_correct))

a = 1×14 cell array {'The'} {'all'} {'day'} {'meetings'} {'will'} {'continue'} {'until'} {'we'} {'learn'} {'why'} {'productivity'} {'is'} {'so'} {'low'} z = 'The' Z = 1×3 uint16 row vector 84 104 101 b = 0 0 0 b = 0 0 0 b = 0 0 0 b = 0 0 1 w = 3 r = 3 z = 'all' Z = 1×3 uint16 row vector 97 108 108 b = 0 0 0 b = 1 0 0 b = 1 0 0 b = 1 0 0 w = 1 r = 1 z = 'day' Z = 1×3 uint16 row vector 100 97 121 b = 0 0 0 b = 0 0 0 b = 0 1 0 b = 0 1 1 w = 2 3 r = 2 3 z = 'meetings' Z = 1×8 uint16 row vector 109 101 101 116 105 110 103 115 b = 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 b = 0 1 1 0 0 0 0 0 b = 0 1 1 0 0 0 0 0 b = 0 1 1 0 1 0 0 0 b = 0 1 1 0 1 0 0 0 b = 0 1 1 0 1 0 0 0 b = 0 1 1 0 1 0 0 0 w = 2 3 5 r = 2 3 4 5 a = 1×14 cell array {'The'} {'all'} {'day'} {0×0 char} {'will'} {'continue'} {'until'} {'we'} {'learn'} {'why'} {'productivity'} {'is'} {'so'} {'low'} z = 'will' Z = 1×4 uint16 row vector 119 105 108 108 b = 0 0 0 0 b = 0 0 0 0 b = 0 1 0 0 b = 0 1 0 0 b = 0 1 0 0 w = 2 r = 2 z = 'continue' Z = 1×8 uint16 row vector 99 111 110 116 105 110 117 101 b = 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 b = 0 1 0 0 1 0 0 0 b = 0 1 0 0 1 0 1 0 b = 0 1 0 0 1 0 1 1 w = 2 5 7 8 r = 2 3 4 5 6 7 8 a = 1×14 cell array {'The'} {'all'} {'day'} {0×0 char} {'will'} {0×0 char} {'until'} {'we'} {'learn'} {'why'} {'productivity'} {'is'} {'so'} {'low'} z = 'until' Z = 1×5 uint16 row vector 117 110 116 105 108 b = 0 0 0 0 0 b = 1 0 0 0 0 b = 1 0 0 0 0 b = 1 0 0 0 0 b = 1 0 0 1 0 b = 1 0 0 1 0 w = 1 4 r = 1 2 3 4 a = 1×14 cell array {'The'} {'all'} {'day'} {0×0 char} {'will'} {0×0 char} {0×0 char} {'we'} {'learn'} {'why'} {'productivity'} {'is'} {'so'} {'low'} z = 'we' Z = 1×2 uint16 row vector 119 101 b = 0 0 b = 0 0 b = 0 1 w = 2 r = 2 z = 'learn' Z = 1×5 uint16 row vector 108 101 97 114 110 b = 0 0 0 0 0 b = 0 0 0 0 0 b = 0 1 0 0 0 b = 0 1 1 0 0 b = 0 1 1 0 0 b = 0 1 1 0 0 w = 2 3 r = 2 3 z = 'why' Z = 1×3 uint16 row vector 119 104 121 b = 0 0 0 b = 0 0 0 b = 0 0 0 b = 0 0 1 w = 3 r = 3 z = 'productivity' Z = 1×12 uint16 row vector 112 114 111 100 117 99 116 105 118 105 116 121 b = 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 1 0 0 0 0 0 0 0 0 0 b = 0 0 1 0 0 0 0 0 0 0 0 0 b = 0 0 1 0 1 0 0 0 0 0 0 0 b = 0 0 1 0 1 0 0 0 0 0 0 0 b = 0 0 1 0 1 0 0 0 0 0 0 0 b = 0 0 1 0 1 0 0 1 0 0 0 0 b = 0 0 1 0 1 0 0 1 0 0 0 0 b = 0 0 1 0 1 0 0 1 0 1 0 0 b = 0 0 1 0 1 0 0 1 0 1 0 0 b = 0 0 1 0 1 0 0 1 0 1 0 1 w = 3 5 8 10 12 r = 3 4 5 6 7 8 9 10 11 12 a = 1×14 cell array {'The'} {'all'} {'day'} {0×0 char} {'will'} {0×0 char} {0×0 char} {'we'} {'learn'} {'why'} {0×0 char} {'is'} {'so'} {'low'} z = 'is' Z = 1×2 uint16 row vector 105 115 b = 0 0 b = 1 0 b = 1 0 w = 1 r = 1 z = 'so' Z = 1×2 uint16 row vector 115 111 b = 0 0 b = 0 0 b = 0 1 w = 2 r = 2 z = 'low' Z = 1×3 uint16 row vector 108 111 119 b = 0 0 0 b = 0 0 0 b = 0 1 0 b = 0 1 0 w = 2 r = 2 A = 1×43 uint16 row vector Columns 1 through 29 84 104 101 32 97 108 108 32 100 97 121 32 32 119 105 108 108 32 32 32 119 101 32 108 101 97 114 110 32 Columns 30 through 43 119 104 121 32 32 105 115 32 115 111 32 108 111 119 A = 1×43 uint16 row vector Columns 1 through 29 84 104 101 32 97 108 108 32 100 97 121 0 32 119 105 108 108 32 32 32 119 101 32 108 101 97 114 110 32 Columns 30 through 43 119 104 121 32 32 105 115 32 115 111 32 108 111 119 A = 1×43 uint16 row vector Columns 1 through 29 84 104 101 32 97 108 108 32 100 97 121 0 32 119 105 108 108 0 32 32 119 101 32 108 101 97 114 110 32 Columns 30 through 43 119 104 121 32 32 105 115 32 115 111 32 108 111 119 A = 1×43 uint16 row vector Columns 1 through 29 84 104 101 32 97 108 108 32 100 97 121 0 32 119 105 108 108 0 0 32 119 101 32 108 101 97 114 110 32 Columns 30 through 43 119 104 121 32 32 105 115 32 115 111 32 108 111 119 A = 1×43 uint16 row vector Columns 1 through 29 84 104 101 32 97 108 108 32 100 97 121 0 32 119 105 108 108 0 0 32 119 101 32 108 101 97 114 110 32 Columns 30 through 43 119 104 121 0 32 105 115 32 115 111 32 108 111 119 s2 = 'The all day will we learn why is so low'

2   Fail
s1 = 'I am perpetually perplexed my big brain notwithstanding'; s2_correct = 'I am my big brain'; assert(isequal(just_short_words(s1),s2_correct))

a = 1×8 cell array {'I'} {'am'} {'perpetually'} {'perplexed'} {'my'} {'big'} {'brain'} {'notwithstanding'} z = 'I' Z = uint16 73 b = 0 b = 1 w = 1 r = 1 z = 'am' Z = 1×2 uint16 row vector 97 109 b = 0 0 b = 1 0 b = 1 0 w = 1 r = 1 z = 'perpetually' Z = 1×11 uint16 row vector 112 101 114 112 101 116 117 97 108 108 121 b = 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 0 0 0 b = 0 1 0 0 1 0 1 0 0 0 0 b = 0 1 0 0 1 0 1 1 0 0 0 b = 0 1 0 0 1 0 1 1 0 0 0 b = 0 1 0 0 1 0 1 1 0 0 0 b = 0 1 0 0 1 0 1 1 0 0 1 w = 2 5 7 8 11 r = 2 3 4 5 6 7 8 9 10 11 a = 1×8 cell array {'I'} {'am'} {0×0 char} {'perplexed'} {'my'} {'big'} {'brain'} {'notwithstanding'} z = 'perplexed' Z = 1×9 uint16 row vector 112 101 114 112 108 101 120 101 100 b = 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 0 b = 0 1 0 0 0 1 0 0 0 b = 0 1 0 0 0 1 0 0 0 b = 0 1 0 0 0 1 0 1 0 b = 0 1 0 0 0 1 0 1 0 w = 2 6 8 r = 2 3 4 5 6 7 8 a = 1×8 cell array {'I'} {'am'} {0×0 char} {0×0 char} {'my'} {'big'} {'brain'} {'notwithstanding'} z = 'my' Z = 1×2 uint16 row vector 109 121 b = 0 0 b = 0 0 b = 0 1 w = 2 r = 2 z = 'big' Z = 1×3 uint16 row vector 98 105 103 b = 0 0 0 b = 0 0 0 b = 0 1 0 b = 0 1 0 w = 2 r = 2 z = 'brain' Z = 1×5 uint16 row vector 98 114 97 105 110 b = 0 0 0 0 0 b = 0 0 0 0 0 b = 0 0 0 0 0 b = 0 0 1 0 0 b = 0 0 1 1 0 b = 0 0 1 1 0 w = 3 4 r = 3 4 z = 'notwithstanding' Z = 1×15 uint16 row vector 110 111 116 119 105 116 104 115 116 97 110 100 105 110 103 b = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 b = 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0 b = 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0 b = 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0 w = 2 5 10 13 r = 2 3 4 5 6 7 8 9 10 11 12 13 a = 1×8 cell array {'I'} {'am'} {0×0 char} {0×0 char} {'my'} {'big'} {'brain'} {0×0 char} A = 1×20 uint16 row vector 73 32 97 109 32 32 32 109 121 32 98 105 103 32 98 114 97 105 110 32 A = 1×20 uint16 row vector 73 32 97 109 0 32 32 109 121 32 98 105 103 32 98 114 97 105 110 32 A = 1×20 uint16 row vector 73 32 97 109 0 0 32 109 121 32 98 105 103 32 98 114 97 105 110 32

Index exceeds the number of array elements (20). Error in just_short_words (line 20) if A(k+1)==32 Error in Test2 (line 3) assert(isequal(just_short_words(s1),s2_correct))

3   Fail
s1 = 'Lazy gravy calico sky ipso facto sweet potato pie'; s2_correct = 'sky sweet pie'; assert(isequal(just_short_words(s1),s2_correct))

a = 1×9 cell array {'Lazy'} {'gravy'} {'calico'} {'sky'} {'ipso'} {'facto'} {'sweet'} {'potato'} {'pie'} z = 'Lazy' Z = 1×4 uint16 row vector 76 97 122 121 b = 0 0 0 0 b = 0 0 0 0 b = 0 1 0 0 b = 0 1 0 0 b = 0 1 0 1 w = 2 4 r = 2 3 4 a = 1×9 cell array {0×0 char} {'gravy'} {'calico'} {'sky'} {'ipso'} {'facto'} {'sweet'} {'potato'} {'pie'} z = 'gravy' Z = 1×5 uint16 row vector 103 114 97 118 121 b = 0 0 0 0 0 b = 0 0 0 0 0 b = 0 0 0 0 0 b = 0 0 1 0 0 b = 0 0 1 0 0 b = 0 0 1 0 1 w = 3 5 r = 3 4 5 a = 1×9 cell array {0×0 char} {0×0 char} {'calico'} {'sky'} {'ipso'} {'facto'} {'sweet'} {'potato'} {'pie'} z = 'calico' Z = 1×6 uint16 row vector 99 97 108 105 99 111 b = 0 0 0 0 0 0 b = 0 0 0 0 0 0 b = 0 1 0 0 0 0 b = 0 1 0 0 0 0 b = 0 1 0 1 0 0 b = 0 1 0 1 0 0 b = 0 1 0 1 0 1 w = 2 4 6 r = 2 3 4 5 6 a = 1×9 cell array {0×0 char} {0×0 char} {0×0 char} {'sky'} {'ipso'} {'facto'} {'sweet'} {'potato'} {'pie'} z = 'sky' Z = 1×3 uint16 row vector 115 107 121 b = 0 0 0 b = 0 0 0 b = 0 0 0 b = 0 0 1 w = 3 r = 3 z = 'ipso' Z = 1×4 uint16 row vector 105 112 115 111 b = 0 0 0 0 b = 1 0 0 0 b = 1 0 0 0 b = 1 0 0 0 b = 1 0 0 1 w = 1 4 r = 1 2 3 4 a = 1×9 cell array {0×0 char} {0×0 char} {0×0 char} {'sky'} {0×0 char} {'facto'} {'sweet'} {'potato'} {'pie'} z = 'facto' Z = 1×5 uint16 row vector 102 97 99 116 111 b = 0 0 0 0 0 b = 0 0 0 0 0 b = 0 1 0 0 0 b = 0 1 0 0 0 b = 0 1 0 0 0 b = 0 1 0 0 1 w = 2 5 r = 2 3 4 5 a = 1×9 cell array {0×0 char} {0×0 char} {0×0 char} {'sky'} {0×0 char} {0×0 char} {'sweet'} {'potato'} {'pie'} z = 'sweet' Z = 1×5 uint16 row vector 115 119 101 101 116 b = 0 0 0 0 0 b = 0 0 0 0 0 b = 0 0 0 0 0 b = 0 0 1 0 0 b = 0 0 1 1 0 b = 0 0 1 1 0 w = 3 4 r = 3 4 z = 'potato' Z = 1×6 uint16 row vector 112 111 116 97 116 111 b = 0 0 0 0 0 0 b = 0 0 0 0 0 0 b = 0 1 0 0 0 0 b = 0 1 0 0 0 0 b = 0 1 0 1 0 0 b = 0 1 0 1 0 0 b = 0 1 0 1 0 1 w = 2 4 6 r = 2 3 4 5 6 a = 1×9 cell array {0×0 char} {0×0 char} {0×0 char} {'sky'} {0×0 char} {0×0 char} {'sweet'} {0×0 char} {'pie'} z = 'pie' Z = 1×3 uint16 row vector 112 105 101 b = 0 0 0 b = 0 0 0 b = 0 1 0 b = 0 1 1 w = 2 3 r = 2 3 A = 1×19 uint16 row vector 32 32 32 115 107 121 32 32 32 115 119 101 101 116 32 32 112 105 101 A = 1×19 uint16 row vector 0 32 32 115 107 121 32 32 32 115 119 101 101 116 32 32 112 105 101 A = 1×19 uint16 row vector 0 0 32 115 107 121 32 32 32 115 119 101 101 116 32 32 112 105 101 A = 1×19 uint16 row vector 0 0 32 115 107 121 0 32 32 115 119 101 101 116 32 32 112 105 101 A = 1×19 uint16 row vector 0 0 32 115 107 121 0 0 32 115 119 101 101 116 32 32 112 105 101 A = 1×19 uint16 row vector 0 0 32 115 107 121 0 0 32 115 119 101 101 116 0 32 112 105 101 s2 = ' sky sweet pie'

Assertion failed.