Cody

Problem 196. love is an n-letter word

Solution 3358923

Submitted on 24 Oct 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   Fail
s1 = {'abcd','bcde','cdef','defg'}; assert(isequal(gobbledigook(s1),'dddd')) s2_correct = 'dddd';

m = 1 4 m = 2 4 m = 3 4

Assertion failed.

2   Fail
s1 = {'aldfejk','czoa','vwy','abcde'}; assert(isequal(gobbledigook(s1),'love')) s2_correct = 'love';

m = 1 7 m = 2 2 m = 3 3

Assertion failed.

3   Fail
s1 = {'some','help','check','viterbi','algorithm'}; assert(isequal(gobbledigook(s1),'eeeeg')) s2_correct = 'eeeeg';

m = 1 3 m = 2 4 m = 3 5 m = 4 7

Assertion failed.

4   Fail
s1 = {'ldjfac','deamv','fka','idlw','pqmfjavs'}; assert(isequal(gobbledigook(s1),'lmklm')|isequal(gobbledigook(s1),'aaadf')) s2_correct = 'lmklm'; s2_correct = 'aaadf';

m = 1 6 m = 2 5 m = 3 2 m = 4 4 m = 1 6 m = 2 5 m = 3 2 m = 4 4

Assertion failed.

5   Fail
% avoids look-up table hack s1 = cellfun(@(x)char('a'-1+randi(26,1,5)),cell(1,7),'uniformoutput',false); assert(all(any(bsxfun(@eq,gobbledigook(s1),cell2mat(cellfun(@(x)x',s1,'uniformoutput',false)))))&all(sum(abs(diff(double(gobbledigook(s1)))))<=sum(abs(diff(double(cell2mat(cellfun(@(x)x(randi(numel(x),1,1000))',s1,'uniformoutput',false))),1,2)),2)));

m = 1 5 m = 2 5 m = 3 5 m = 4 5 m = 5 5 m = 6 5

Error using bsxfun Non-singleton dimensions of the two input arrays must match each other. Error in Test5 (line 3) assert(all(any(bsxfun(@eq,gobbledigook(s1),cell2mat(cellfun(@(x)x',s1,'uniformoutput',false)))))&all(sum(abs(diff(double(gobbledigook(s1)))))<=sum(abs(diff(double(cell2mat(cellfun(@(x)x(randi(numel(x),1,1000))',s1,'uniformoutput',false))),1,2)),2)));

Suggested Problems

More from this Author38

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!