Cody

# Problem 466. Compress strings (not springs)

Solution 1108137

Submitted on 20 Jan 2017 by JD
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
x='Blogs , Trendy , Cody , Contest .'; y='Blogs, Trendy, Cody, Contest.'; assert(isequal(cozy_cody(x),y))

ans = 45 ans = Columns 1 through 16 66 108 111 103 115 32 32 44 32 32 32 32 84 114 101 110 Columns 17 through 32 100 121 32 32 44 32 32 32 32 67 111 100 121 32 32 44 Columns 33 through 45 32 32 32 32 67 111 110 116 101 115 116 32 46 ans = 1 ans = Blogs , Trendy , Cody , Contest . ans = Blogs, Trendy, Cody, Contest.

2   Pass
x='Trendy , Cody , Contest .'; y='Trendy, Cody, Contest.'; assert(isequal(cozy_cody(x),y))

ans = 71 ans = Columns 1 through 16 84 114 101 110 100 121 32 44 32 32 32 32 32 32 32 32 Columns 17 through 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 67 111 Columns 33 through 48 100 121 32 44 32 32 32 32 32 32 32 32 32 32 32 32 Columns 49 through 64 32 32 32 32 32 32 32 32 32 32 32 32 32 32 67 111 Columns 65 through 71 110 116 101 115 116 32 46 ans = 1 ans = Trendy , Cody , Contest . ans = Trendy, Cody, Contest.

3   Pass
x='One Two Three Four Five Six Seven Eight Nine Ten'; y='One Two Three Four Five Six Seven Eight Nine Ten'; assert(isequal(cozy_cody(x),y))

ans = 84 ans = Columns 1 through 16 79 110 101 32 84 119 111 32 32 84 104 114 101 101 32 32 Columns 17 through 32 32 70 111 117 114 32 32 32 32 70 105 118 101 32 32 32 Columns 33 through 48 32 32 83 105 120 32 32 32 32 32 32 83 101 118 101 110 Columns 49 through 64 32 32 32 32 32 32 32 69 105 103 104 116 32 32 32 32 Columns 65 through 80 32 32 32 32 78 105 110 101 32 32 32 32 32 32 32 32 Columns 81 through 84 32 84 101 110 ans = 1 ans = One Two Three Four Five Six Seven Eight Nine Ten ans = One Two Three Four Five Six Seven Eight Nine Ten

4   Pass
x='1, 2, 3, 4, 5, 6, 7, 8, 9, 10'; y='1, 2, 3, 4, 5, 6, 7, 8, 9, 10'; assert(isequal(cozy_cody(x),y))

ans = 65 ans = Columns 1 through 16 49 44 32 50 44 32 32 51 44 32 32 32 52 44 32 32 Columns 17 through 32 32 32 53 44 32 32 32 32 32 54 44 32 32 32 32 32 Columns 33 through 48 32 55 44 32 32 32 32 32 32 32 56 44 32 32 32 32 Columns 49 through 64 32 32 32 32 57 44 32 32 32 32 32 32 32 32 32 49 Column 65 48 ans = 1 ans = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ans = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

5   Pass
x='1 , and 3 , and 7 , and 12'; y='1, and 3, and 7, and 12'; assert(isequal(cozy_cody(x),y))

ans = 60 ans = Columns 1 through 16 49 32 32 32 44 32 97 110 100 32 51 32 32 44 32 32 Columns 17 through 32 97 110 100 32 55 32 44 32 32 32 97 110 100 32 32 32 Columns 33 through 48 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 Columns 49 through 60 32 32 32 32 32 32 32 32 32 32 49 50 ans = 1 ans = 1 , and 3 , and 7 , and 12 ans = 1, and 3, and 7, and 12

6   Pass
x='Hello There !'; y='Hello There!'; assert(isequal(cozy_cody(x),y))

ans = 65 ans = Columns 1 through 16 72 101 108 108 111 32 32 32 32 32 32 32 32 32 32 32 Columns 17 through 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 Columns 33 through 48 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 Columns 49 through 64 32 84 104 101 114 101 32 32 32 32 32 32 32 32 32 32 Column 65 33 ans = 1 ans = Hello There ! ans = Hello There!

### Community Treasure Hunt

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

Start Hunting!