Abdul has created a naming convention for places (countries, cities, streets, etc.). Words are composed of sections. There are three valid types of sections: A, B and C. The following elements are categorized into section A: ch
, t
, m
, d
, b
, bd
, r
. The following elements are categorized into section B: a
, e
, i
, oo
. Finally, the following elements are categorized into section C: n
, v
, f
. Valid words are composed of sections that follow strict placement rules. A word may start with either section A or B. A word must be at least 2 sections in length. A word cannot have two consecutive sections of the same type. A word must end with either section A or C. Section C can only end a word, and thus not exist anywhere else. A name consists of two or more words. The case is not relevant.
Given a name, check whether or not it is a valid name, according to the naming convention explained above. If it is valid, output valid
otherwise, output invalid
.
Input Specification
A single line with a name containing words. Each word has letters.
Output Specification
valid
or invalid
depending on whether the name given was a valid or invalid name according to Abdul's naming convention.
Sample Input 1
Abdoof Arif
Sample Output 1
valid
Sample Input 2
Abdul
Sample Output 2
invalid
Explanation for Sample Output 2
First of all, the word Abdul
is not a valid word. Secondly, there is only 1 word in the name.
Comments
Can you add the number of words as the first line so it is solvable in Turing?
Considering that so many users have already solved the problem, it would be too much of a hassle to change the format of the input (many AC solutions would then become WA on the new test data). However, you can read in each word separately and have a counter etc. Use
exit when eof
to read until the end of input. See here for more details. (scroll down)Thanks for responding and informing me about eof!
should our program be case sensitive?
the case doesn't matter
thanks