Cody

Solution 2025376

Submitted on 17 Nov 2019 at 17:25 by Romain Demory
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
list = {'Barney Google','Snuffy Smith','Dagwood Bumstead'}; alpha_list = {'Dagwood Bumstead','Barney Google','Snuffy Smith'} assert(isequal(alphabetize(list),alpha_list))

alpha_list = 1×3 cell array {'Dagwood Bumstead'} {'Barney Google'} {'Snuffy Smith'} indexFirstLetter = 8 firstLetter = 'G' indexFirstLetter = 8 8 firstLetter = 'GS' indexFirstLetter = 8 8 9 firstLetter = 'GSB' I = 3 1 2 alpha_list = 1×3 cell array {'Dagwood Bumstead'} {'Barney Google'} {'Snuffy Smith'}

2   Pass
list = {'Harry Truman' 'Dwight Eisenhower' 'John F. Kennedy' 'Lyndon Johnson' 'Richard Nixon' 'Gerald Ford' 'Cleve Moler' 'Ronald Reagan' 'George Bush' 'Bill Clinton' 'George Bush' 'Barack Obama'}; alpha_list = {'George Bush' 'George Bush' 'Bill Clinton' 'Dwight Eisenhower' 'Gerald Ford' 'Lyndon Johnson' 'John F. Kennedy' 'Cleve Moler' 'Richard Nixon' 'Barack Obama' 'Ronald Reagan' 'Harry Truman'} assert(isequal(alphabetize(list),alpha_list))

alpha_list = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Cleve Moler' } {'Richard Nixon' } {'Barack Obama' } {'Ronald Reagan' } {'Harry Truman' } indexFirstLetter = 7 firstLetter = 'T' indexFirstLetter = 7 8 firstLetter = 'TE' indexFirstLetter = 7 8 9 firstLetter = 'TEK' indexFirstLetter = 7 8 9 8 firstLetter = 'TEKJ' indexFirstLetter = 7 8 9 8 9 firstLetter = 'TEKJN' indexFirstLetter = 7 8 9 8 9 8 firstLetter = 'TEKJNF' indexFirstLetter = 7 8 9 8 9 8 7 firstLetter = 'TEKJNFM' indexFirstLetter = 7 8 9 8 9 8 7 8 firstLetter = 'TEKJNFMR' indexFirstLetter = 7 8 9 8 9 8 7 8 8 firstLetter = 'TEKJNFMRB' indexFirstLetter = 7 8 9 8 9 8 7 8 8 6 firstLetter = 'TEKJNFMRBC' indexFirstLetter = 7 8 9 8 9 8 7 8 8 6 8 firstLetter = 'TEKJNFMRBCB' indexFirstLetter = 7 8 9 8 9 8 7 8 8 6 8 8 firstLetter = 'TEKJNFMRBCBO' I = 9 11 10 2 6 4 3 7 5 12 8 1 alpha_list = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Cleve Moler' } {'Richard Nixon' } {'Barack Obama' } {'Ronald Reagan' } {'Harry Truman' }

Suggested Problems

More from this Author95