What about y in the second test?
Why isn't y a vowel in english? In swedish we have nine vowels and y is one of them.
There is only five vowels in English.That is 'a,e,i,o,u'.
I don't understand why the following doesn't work:
expression = '[aeiouAEIOU]';
[~,noMatch] = regexp(s1,expression,'match','split');
[~,c] = size(noMatch);
cell_s2 = '';
for i = 1:c
cell_s2 = strcat(cell_s2,noMatch(i));
end
s2 = string(cell_s2);
nice
#WARNING
Character Array And String are not similar.
length('abc')
% 3
length("abc")
% 1
so 'abc' is NOT EQUAL to "abc"
use "char" function to get character array from string
char("abc")
% 'abc'
using
if ~any(s1(i) == 'aeiouAEIOU')
makes it real easy
The letters 'w' and 'y' are actually vowels.
(Perhaps not in Cody, perhaps not even in American English - I am not sure - but for certain they are in English...)
function s2 = refcn(s1)
s2 = [];
s3='aAeEiIoOuU';
L=strlength(s1);
L1=strlength(s3);
flag=0;
j=1;
for i=1:L
for k=1:L1
if s1(i)==s3(k)
flag=1;
continue;
end
end
if flag==0
s2(j)=s1(i);
j=j+1;
end
flag=0;
end
end
why no accept
I can't make this work on my PC (Matlab 2016 doesn't support double quotes and string arrays)
s1 = 'I don''t want to work. I just want to bang on the drum all day.';
How it is possible to read the string to the s1 including another quote at don''t
including lower() helped me with the capital I
'Y' is being considered as a consonant!
In addition to vowels, the second test also removes a space. While it's natural to want to clean up extra spaces, spaces are _not_ vowels.
The display of the test suite show the second space at the "I" being removed, but the actual test does not remove it. This is very confusing, but the test actually works as you would expect. It is just that the displayed "correct" answer is - in fact - not correct as you noted.
I had trouble with this as I saw your answer and accommodated their "error" in my solution. Except their error was only a display error and not an actual error in the test suite. Doh!
See https://www.mathworks.com/matlabcentral/cody/problems/22-remove-the-vowels/solutions/1218453 for a repaired version of your solution.
Of course I just noted that your solution is five months old, so you certainly won't care by now. C'est la vie.
Also should include other capitals
Anyone can see why this is not working? Works fine on my side.
Consider letter 'y'. It can be consonant or vowel, depend on context. More: http://en.wikipedia.org/wiki/Consonant#Letters
Initially I tried both ways with same results. My mistake was forgetting about the capital vowels. Thanks for the reply Jan.
very good solution!
can any one say what is the problem if we approch through ascii representation?
excellent example!
one "'" can make a very different situation between "regexp" and "regexpi".
For the second test-case, something is wrong.
* If you use the string that is given in S1 in MATLAB, you do NOT get the output that is listed.
* However, to get the output that is listed as the correct one, you cannot have the input that is given.
Regexp is apparently unable to detect the 'y' at the end of 'day'. This does not happen on my own computer. Very strange indeed.
Smaller but less explicit than 'ignorecase'. Anyway, good solution.
On my pc it works. Why not here?
Wait... how is this:
s2 = regexprep(s1,'[aeiouAEIOU]','');
s2 = s1(regexpi(s1,'[^aeiou]'));
@Tom
I believe it is because the regexpi would be the same as including the 'ignorecase' option from regexprep command (including that makes the size 15).
Does it really matter if y is a vowel or not? XD
y or y not!!
thats the problem...
1270 Solvers
Reverse the Words (not letters) of a String
298 Solvers
Project Euler: Problem 9, Pythagorean numbers
295 Solvers
518 Solvers
1165 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!