Cody

Solution 1910895

Submitted on 24 Aug 2019 by Tetsuji Tsuda
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'} last = 0×0 empty cell array idx = [] sp = 2×1 cell array {'Barney'} {'Google'} last = 1×1 cell array {'Google'} sp = 2×1 cell array {'Snuffy'} {'Smith' } last = 1×2 cell array {'Google'} {'Smith'} sp = 2×1 cell array {'Dagwood' } {'Bumstead'} last = 1×3 cell array {'Google'} {'Smith'} {'Bumstead'} idx = 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' } last = 0×0 empty cell array idx = [] sp = 2×1 cell array {'Harry' } {'Truman'} last = 1×1 cell array {'Truman'} sp = 2×1 cell array {'Dwight' } {'Eisenhower'} last = 1×2 cell array {'Truman'} {'Eisenhower'} sp = 3×1 cell array {'John' } {'F.' } {'Kennedy'} last = 1×3 cell array {'Truman'} {'Eisenhower'} {'Kennedy'} sp = 2×1 cell array {'Lyndon' } {'Johnson'} last = 1×4 cell array {'Truman'} {'Eisenhower'} {'Kennedy'} {'Johnson'} sp = 2×1 cell array {'Richard'} {'Nixon' } last = 1×5 cell array {'Truman'} {'Eisenhower'} {'Kennedy'} {'Johnson'} {'Nixon'} sp = 2×1 cell array {'Gerald'} {'Ford' } last = 1×6 cell array {'Truman'} {'Eisenhower'} {'Kennedy'} {'Johnson'} {'Nixon'} {'Ford'} sp = 2×1 cell array {'Cleve'} {'Moler'} last = 1×7 cell array {'Truman'} {'Eisenhower'} {'Kennedy'} {'Johnson'} {'Nixon'} {'Ford'} {'Moler'} sp = 2×1 cell array {'Ronald'} {'Reagan'} last = 1×8 cell array {'Truman'} {'Eisenhower'} {'Kennedy'} {'Johnson'} {'Nixon'} {'Ford'} {'Moler'} {'Reagan'} sp = 2×1 cell array {'George'} {'Bush' } last = 1×9 cell array {'Truman'} {'Eisenhower'} {'Kennedy'} {'Johnson'} {'Nixon'} {'Ford'} {'Moler'} {'Reagan'} {'Bush'} sp = 2×1 cell array {'Bill' } {'Clinton'} last = 1×10 cell array {'Truman'} {'Eisenhower'} {'Kennedy'} {'Johnson'} {'Nixon'} {'Ford'} {'Moler'} {'Reagan'} {'Bush'} {'Clinton'} sp = 2×1 cell array {'George'} {'Bush' } last = 1×11 cell array {'Truman'} {'Eisenhower'} {'Kennedy'} {'Johnson'} {'Nixon'} {'Ford'} {'Moler'} {'Reagan'} {'Bush'} {'Clinton'} {'Bush'} sp = 2×1 cell array {'Barack'} {'Obama' } last = 1×12 cell array {'Truman'} {'Eisenhower'} {'Kennedy'} {'Johnson'} {'Nixon'} {'Ford'} {'Moler'} {'Reagan'} {'Bush'} {'Clinton'} {'Bush'} {'Obama'} idx = 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' }