Cody

# Problem 61. Find state names that end with the letter A

Solution 3740698

Submitted on 20 Nov 2020
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   Fail
s1 = 'Alabama Montana Nebraska Vermont Nevada'; s2 = ' Vermont '; assert(isequal(s2, refcn(s1)))

i = 8 16 25 33

Array indices must be positive integers or logical values. Error in refcn (line 5) s1(i(k-1):i(k)) = '' Error in Test1 (line 3) assert(isequal(s2, refcn(s1)))

2   Fail
s1 = 'Alabama Alaska Arizona Arkansas California Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois Indiana Iowa Kansas Kentucky Louisiana Maine Maryland Massachusetts Michigan Minnesota'; s2 = ' Arkansas Colorado Connecticut Delaware Hawaii Idaho Illinois Kansas Kentucky Maine Maryland Massachusetts Michigan '; assert(isequal(s2, refcn(s1)))

i = 8 15 23 32 43 52 64 73 81 89 96 102 111 119 124 131 140 150 156 165 179 188

Array indices must be positive integers or logical values. Error in refcn (line 5) s1(i(k-1):i(k)) = '' Error in Test2 (line 5) assert(isequal(s2, refcn(s1)))

3   Fail
s1 = 'New York North Carolina Michigan Arkansas Alabama North Dakota Hawaii West Virginia New Jersey'; s2 = 'New York Michigan Arkansas Hawaii New Jersey'; assert(isequal(s2, refcn(s1)))

i = 4 9 15 24 33 42 50 56 63 70 75 84 88 s1 = 'New York NorthMichigan Arkansas Alabama North Dakota Hawaii West Virginia New Jersey' s1 = 'New York NorthMichigan Arkansas Alabama North Dakaii West Virginia New Jersey'

Index exceeds the number of array elements (77). Error in refcn (line 4) if s1(i(k)-1)=='a' Error in Test3 (line 5) assert(isequal(s2, refcn(s1)))

### Community Treasure Hunt

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

Start Hunting!