Problem 61. Find state names that end with the letter A
Solution Stats
Problem Comments
-
9 Comments
I believe this problem has the wrong assertion for part 2. The space rule seems to be to keep spaces between words unless it is something like North Dakota in which you delete the space between the two words. Missouri New Hampshire seems to be missing a space, as only 3 are present. With three entries to delete there should be four spaces Missourix1x2x3xNew (4 x's or spaces for 3 matches).
There's an error in the second test case. This is what's returned: "Error: Error: A MATLAB string constant is not terminated properly." I assume this is due to there being an accidental new-line character in the input string.
I've cleaned up the second test. There was a bad character in there somewhere, but it's working now and I've rescored all the answers.
I get the infamous "Remove inappropriate content" message when trying to submit a solution to this problem.
This is a bizarre one - test case is dependent on how many spaces are between the state names, which points to a specific solution having to be used rather than a solution that makes sense to the user.
Additionally, I have noticed a stange effect in 19a when I use "join". My solution has too few spaces between "Delaware" and "Hawaii", so I thought I'd just bung another one in there with "join". If I do:
s2 = cell2mat(join(s2," ")), % I get the same number of spaces
s2 = cell2mat(join(s2," ")) % I get too many spaces!
Driving me wild...
@Kiran Ramsaroop, instructions are to remove state names, not spaces. It may seem silly to want this, but it is accurate.
Thus only spaces that are part of a removed state name should be removed.
tough
Be careful of the 2-word states.
Converting to different formats boggles me
I don't want to go through to effort to solve such a irrelevant problem!
I will cheat!
if (s1{id}(1) == 'W' & s1{id}(end) == 't') | s1{id}(end) == 'h'
% Do nothing...
Solution Comments
-
1 Comment
Pay attention to the third case!It includes two-word name and one-word name.
-
1 Comment
Can you help?
-
1 Comment
s2 = ' Vermont ';
Here the task is to extract the word but result contained extra spaces????
-
1 Comment
check your test case with my programme. It passes all test suite case in MATALB 2017b but not passing the test suite here.
-
1 Comment
Ah - two word states count, like North Dakota.
Problem Recent Solvers1044
Suggested Problems
-
319 Solvers
-
Arrange vector in ascending order
728 Solvers
-
We love vectorized solutions. Problem 1 : remove the row average.
761 Solvers
-
478 Solvers
-
Solving Quadratic Equations (Version 1)
470 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!