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.
function s2 = refcn(s1)
s2='';
k=1;
flag=0;
L=strlength(s1);
s3='BbCcDdFfGgHhJjKkLlMmNnPpQqRrSsTtVvWwXxYyZz';
L1=strlength(s3);
for i=1:L
for j=1:L1
if s1(i)==s3(j)
flag=1;
continue;
end
end
if flag==0
s2(k)=s1(i);
k=k+1;
end
flag=0;
end
end
Can someone help me understand why this solution doesn't work? It may have something to do with the data types perhaps?
%Remove the consonants from a string
function s2 = refcn(s1)
L = length(s1);
matches = 0;
%increment through s1
for i = 1:L
flag = 0;
%compare the current letter to a vowel
if s1(i) == 'a'
flag = 1;
matches = matches + 1;
elseif s1(i) == 'e'
flag = 1;
matches = matches + 1;
elseif s1(i) == 'i'
flag = 1;
matches = matches + 1;
elseif s1(i) == 'o'
flag = 1;
matches = matches + 1;
elseif s1(i) == 'u'
flag = 1;
matches = matches + 1;
end
%Insert the matching vowel and a space
if flag == 1
s2(matches) = s1(i);
matches = matches + 1;
s2(matches + 1) = ' ';
end
end
end
Y is no consonnant to me, but ok
Should clarify that 'y' is treated as a consonant.
It seems to be a mistake - in the second test S1 includes 'y' .That is not consonant, but the output S2 has not it.
tai tama nan le:)
wo hao nan a
y is a vowel !
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.
take me some time to do ...
doc regexprep :'(?=[a-z])[^aeiou]' matches consonants.
I think is the best solution!
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!
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.
and y in test 2
can anyone help me solve this problem.
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?
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..
the solution is not very pretty, try regular expressions
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
just joking
lol y ^^
Generally "y" is not considered a consonant
5923 Solvers
Find the alphabetic word product
2354 Solvers
Project Euler: Problem 8, Find largest product in a large string of numbers
337 Solvers
Longest run of consecutive numbers
1978 Solvers
Check that number is whole number
1232 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!