3136
This commit is contained in:
33
src/3136.c
Normal file
33
src/3136.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <ctype.h>
|
||||
#include <solution/3136.h>
|
||||
|
||||
bool isVowel(char c)
|
||||
{
|
||||
return c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' || c == 'o' || c == 'O' || c == 'u' ||
|
||||
c == 'U';
|
||||
}
|
||||
|
||||
bool isConsonant(char c)
|
||||
{
|
||||
return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) && !isVowel(c);
|
||||
}
|
||||
|
||||
bool isValid(char *word)
|
||||
{
|
||||
int length = 0;
|
||||
bool haveVowel = false;
|
||||
bool haveConsonant = false;
|
||||
|
||||
for (; *word != '\0'; word++, length++)
|
||||
{
|
||||
haveVowel = haveVowel || isVowel(*word);
|
||||
haveConsonant = haveConsonant || isConsonant(*word);
|
||||
if (!isdigit(*word) && !isVowel(*word) && !isConsonant(*word))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (length < 3)
|
||||
return false;
|
||||
|
||||
return haveVowel && haveConsonant;
|
||||
}
|
||||
Reference in New Issue
Block a user