Given a list of US states, remove all the states that end with the letter A.
Input s1 = 'Alabama Montana Nebraska Vermont Nevada';
Output s2 is ' Vermont ';
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.
Can you help?
s2 = ' Vermont ';
Here the task is to extract the word but result contained extra spaces????
check your test case with my programme. It passes all test suite case in MATALB 2017b but not passing the test suite here.
Ah - two word states count, like North Dakota.
Make a Palindrome Number
Maximum running product for a string of numbers
Number of 1s in the Binary Representation of a Number
Divide by 4
Calculate the Levenshtein distance between two strings
Implement a ROT13 cipher
Get the area codes from a list of phone numbers
Which doors are open?
Read a column of numbers and interpolate missing data
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office