Cody

# Problem 44. Trimming Spaces

Solution 60117

Submitted on 12 Mar 2012 by Dan K
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)))

x = Columns 1 through 10 115 101 99 97 112 115 32 97 114 116 Columns 11 through 15 120 101 32 111 110 b = no extra spaces

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

x = Columns 1 through 10 116 110 111 114 102 32 110 105 32 101 Columns 11 through 20 99 97 112 115 32 102 111 32 115 116 Columns 21 through 22 111 108 b = lots of space in front

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

x = Columns 1 through 10 32 32 32 32 32 32 107 99 97 98 Columns 11 through 20 32 110 105 32 101 99 97 112 115 32 Columns 21 through 27 102 111 32 115 116 111 108 b = lots of space in back

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

x = Columns 1 through 10 32 32 32 32 115 101 100 105 115 32 Columns 11 through 20 104 116 111 98 32 110 111 32 101 99 Columns 21 through 23 97 112 115 b = space on both sides

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

x = Columns 1 through 10 32 32 32 32 100 110 101 32 116 97 Columns 11 through 20 32 101 99 97 112 115 32 44 116 110 Columns 21 through 30 111 114 102 32 110 105 32 98 97 116 Column 31 9 b = tab in front, space at end

### Community Treasure Hunt

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

Start Hunting!