Note: this is lifted directly from Puzzler for a Monday (on MATLAB Answers) by the cyclist.
----
Given a cell array of strings
A = {'MATLAB','HURRAY','SPARKLY','KITTENS','FUN'};
and a particular string value
B = 'KITTENS';
ensure that B is the last element of the cell array. If it isn't, move it to the end of A.
You cannot assume that B appears at all (in which case return A unchanged), but you can assume B does not appear more than once.
So in the example,
C = {'MATLAB','HURRAY','SPARKLY','FUN','KITTENS'};
Which values occur exactly three times?
3306 Solvers
Make one big string out of two smaller strings
1070 Solvers
Find the maximum number of decimal places in a set of numbers
156 Solvers
Create matrix of replicated elements
266 Solvers
1228 Solvers
Problem Tags