Cody

# Problem 44. Trimming Spaces

Solution 425828

Submitted on 4 Apr 2014 by Mick Warehime
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 = 'no extra spaces'; b = 'no extra spaces'; assert(isequal(b,removeSpaces(a)))

done = 0 sze = 1 15 in = Empty matrix: 1-by-0 a = no extra spaces done = 1

2   Pass
%% a = ' lots of space in front'; b = 'lots of space in front'; assert(isequal(b,removeSpaces(a)))

done = 0 sze = 1 28 in = 1 a = lots of space in front done = 0 sze = 1 27 in = 1 a = lots of space in front done = 0 sze = 1 26 in = 1 a = lots of space in front done = 0 sze = 1 25 in = 1 a = lots of space in front done = 0 sze = 1 24 in = 1 a = lots of space in front done = 0 sze = 1 23 in = 1 a = lots of space in front done = 0 sze = 1 22 in = Empty matrix: 1-by-0 a = lots of space in front done = 1

3   Pass
%% a = 'lots of space in back '; b = 'lots of space in back'; assert(isequal(b,removeSpaces(a)))

done = 0 sze = 1 27 in = 27 a = lots of space in back done = 0 sze = 1 26 in = 26 a = lots of space in back done = 0 sze = 1 25 in = 25 a = lots of space in back done = 0 sze = 1 24 in = 24 a = lots of space in back done = 0 sze = 1 23 in = 23 a = lots of space in back done = 0 sze = 1 22 in = 22 a = lots of space in back done = 0 sze = 1 21 in = Empty matrix: 1-by-0 a = lots of space in back done = 1

4   Pass
%% a = ' space on both sides '; b = 'space on both sides'; assert(isequal(b,removeSpaces(a)))

done = 0 sze = 1 29 in = 1 29 a = space on both sides done = 0 sze = 1 27 in = 1 27 a = space on both sides done = 0 sze = 1 25 in = 1 25 a = space on both sides done = 0 sze = 1 23 in = 1 23 a = space on both sides done = 0 sze = 1 21 in = 1 a = space on both sides done = 0 sze = 1 20 in = 1 a = space on both sides done = 0 sze = 1 19 in = Empty matrix: 1-by-0 a = space on both sides done = 1

5   Pass
%% a = sprintf('\ttab in front, space at end '); b = sprintf('\ttab in front, space at end'); assert(isequal(b,removeSpaces(a)))

done = 0 sze = 1 31 in = 31 a = tab in front, space at end done = 0 sze = 1 30 in = 30 a = tab in front, space at end done = 0 sze = 1 29 in = 29 a = tab in front, space at end done = 0 sze = 1 28 in = 28 a = tab in front, space at end done = 0 sze = 1 27 in = Empty matrix: 1-by-0 a = tab in front, space at end done = 1