Problem 13. Remove all the consonants
Solution Stats
Problem Comments
-
17 Comments
I agree with the comments below, the test suite does not match the problem description.
Agreed.
Fixing and rescoring. Sorry about the confusion.
Though I think technically the problem description is correct, it would be much more understandable if you show what to do with punctuation as well.
Also, from the example it is not clear what one should do if two vowels exists in one word. Since it is not asked in the test-suite, maybe note explicitly that you can assume that every word will have one vowel at the most.
interesting
http://www.oxforddictionaries.com/words/is-the-letter-y-a-vowel-or-a-consonant
In the answer, spaces separate remaining characters except when preceeding punctuation!
I keep getting "There was an issue submitting your solution. Remove inappropriate content." No idea why.
This is just a "corollary" to the problem of removing vowels (with the same sample sentence!)
Brian Butler the spaces in the original sentence were included in the new sentence. It just seems the way you said it due to there being one vowel per word in the original.
I after 500 like i gave up but could distinguish between the two, I just wrote if and else and typed the thing. That counts right. XD I have no clue. lol I turned them into a double into a double figured out ' = 39 , space = 32 . = 46, It started Numbers = double(s1); Then I made vow = double(['AaEeIiOoUu.','''']) nothing wrong with that stuff. First one easy. The periods and little squirt marks in the second one. DX so stuck. Should I break it in two at the squirts and just make 2 strings. That's what I am thinking. It seem to have a mind of its own in the current form. It is just the spaces.
More test cases could be added as well. Such as if the sentence includes numbers, whitespaces, e.t.c.
i hate this problem
After executing the the input string
s1 = 'I don''t want to work. I just want to bang on the drum all day.'
it is reading as single quote at "don''t " word but in the result both quotes are shown how it is possible????
The vowels to retain here are, 'a e i o u'. There appears to be confusion for some.
To solve this question, the best way is to delete consonants rather than to find 'a e i o u' and other things.
To be honest, although I know why there are two ' in the second test, I don't know how to detect it.
So, I give up and I choose to delete consonants. /(ㄒoㄒ)/~~
@mustafizur because you are not doing what is being asked
Solution Comments
-
1 Comment
Tricky problem, particularly because text is not clear enough. It is not clear how spaces and other text symbols should be treated (there are spaces between vowels, but not between a vowel and a period). This turns to come up naturally after figuring out the solution.
Hint: consider detect state functions
-
1 Comment
The double apostrophe in test 2 did strange things to the parsing so I hardcoded the solution to test 2, but my solution for test 1 is correct.
-
1 Comment
Y is no consonnant to me, but ok
-
1 Comment
???
-
1 Comment
Should clarify that 'y' is treated as a consonant.
-
1 Comment
It seems to be a mistake - in the second test S1 includes 'y' .That is not consonant, but the output S2 has not it.
-
2 Comments
tai tama nan le:)
wo hao nan a
-
2 Comments
y is a vowel !
off course not!
-
2 Comments
Why are there 2 apostrophes in answer of 2nd test?
Because if you do not double up (''), the single apostrophe is read by MATLAB as the end of the character vector. This is how you get around this.
-
1 Comment
take me some time to do ...
-
2 Comments
doc regexprep :'(?=[a-z])[^aeiou]' matches consonants.
I think is the best solution!
-
2 Comments
Hi, I really like your solution.much easier than mine
this solution just pass the test suite, but if there would be uppercase consonants, will fail!
The variable letter must contain the uppercase consonants too!
-
2 Comments
s1 = 'Jack and Jill went up the hill';
s2 = 'a a i e u e i';
assert(isequal(s2,refcn(s1)))
a = [] n = 30 s2 = [] a = 'a' s2 = 'a' s2 = 'a' s2 = 'a' s2 = 'a' a = 'aa' s2 = 'aa' s2 = 'aa' s2 = 'aa' s2 = 'aa' s2 = 'aa' a = 'aai' s2 = 'aai' s2 = 'aai' s2 = 'aai' s2 = 'aai' s2 = 'aai' a = 'aaie' s2 = 'aaie' s2 = 'aaie' s2 = 'aaie' s2 = 'aaie' a = 'aaieu' s2 = 'aaieu' s2 = 'aaieu' s2 = 'aaieu' s2 = 'aaieu' s2 = 'aaieu' a = 'aaieue' s2 = 'aaieue' s2 = 'aaieue' s2 = 'aaieue' a = 'aaieuei' s2 = 'aaieuei' s2 = 'aaieuei' s2 = 'aaieuei'
explain me why it doesn't work?
Two things: (1) "y" is not normally considered a vowel, in everyday contexts; (2) you are omitting the spaces shown in s2 in the target solutions.
-
1 Comment
and y in test 2
-
1 Comment
can anyone help me solve this problem.
-
3 Comments
function ans = refcn(s1)
regexprep(s1,'(?=[a-z])[^aeiou]', ' ','preservecase');
end
not working help me
write like this
s2=regexprep(s1,'(?![aeiou])[a-z]','','ignorecase');
Raihan Ahmed, I know this comment is years old, but could you explain how the input '(?![aeiou])[a-z]' works? Obviously, MatLab recognises it as the same thing as '[b,c,d,f,g,h,j,k,l,m,n,p,q,r,s,t,v,w,x,y,z]', but what exactly is it doing?
-
1 Comment
It looks like the test suit was modified and former solutions that were working are not working anymore.. so we are not competing on the same playground with new solutions..
-
1 Comment
the solution is not very pretty, try regular expressions
-
1 Comment
s1 = 'I don''t want to work. I just want to bang on the drum all day.';
the second case seems does not fit the meaning of the qustion! and l think it is totally unnecessary
-
1 Comment
just joking
-
1 Comment
lol y ^^
-
1 Comment
Generally "y" is not considered a consonant
Problem Recent Solvers3748
Suggested Problems
-
Select every other element of a vector
28205 Solvers
-
2011 Solvers
-
454 Solvers
-
Project Euler: Problem 10, Sum of Primes
1327 Solvers
-
708 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!