Cody

# Problem 1755. Fix the last element of a cell array

Solution 1884633

Submitted on 26 Jul 2019 by Nikolaos Nikolaou
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
A = {'MATLAB','HURRAY','SPARKLY','KITTENS','FUN'}; B = 'KITTENS'; C = {'MATLAB','HURRAY','SPARKLY','FUN','KITTENS'}; assert(isequal(puzzler(A,B),C))

IndexC = 1×5 cell array {0×0 double} {0×0 double} {0×0 double} {[1]} {0×0 double} Index = 4 C = 1×5 cell array {'MATLAB'} {'HURRAY'} {'SPARKLY'} {0×0 double} {'FUN'} C = 1×4 cell array {'MATLAB'} {'HURRAY'} {'SPARKLY'} {'FUN'} C = 1×5 cell array {'MATLAB'} {'HURRAY'} {'SPARKLY'} {'FUN'} {'KITTENS'}

2   Pass
A = {'HELP!','I''VE','FALLEN','ON THE','CAPS LOCK','KEY'}; B = 'stop shouting'; C = {'HELP!','I''VE','FALLEN','ON THE','CAPS LOCK','KEY'}; assert(isequal(puzzler(A,B),C))

IndexC = 1×6 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} Index = 1×0 empty double row vector

3   Pass
A = {'When','in the','human events','course','of'}; B = 'human events'; C = {'When','in the','course','of','human events'}; assert(isequal(puzzler(A,B),C))

IndexC = 1×5 cell array {0×0 double} {0×0 double} {[1]} {0×0 double} {0×0 double} Index = 3 C = 1×5 cell array {'When'} {'in the'} {0×0 double} {'course'} {'of'} C = 1×4 cell array {'When'} {'in the'} {'course'} {'of'} C = 1×5 cell array {'When'} {'in the'} {'course'} {'of'} {'human events'}

4   Pass
A = {'Soulwise','these','times','are','trying'}; B = 'times'; C = {'Soulwise','these','are','trying','times'}; assert(isequal(puzzler(A,B),C))

IndexC = 1×5 cell array {0×0 double} {0×0 double} {[1]} {0×0 double} {0×0 double} Index = 3 C = 1×5 cell array {'Soulwise'} {'these'} {0×0 double} {'are'} {'trying'} C = 1×4 cell array {'Soulwise'} {'these'} {'are'} {'trying'} C = 1×5 cell array {'Soulwise'} {'these'} {'are'} {'trying'} {'times'}

### Community Treasure Hunt

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

Start Hunting!