Mackenzie New Year's Challenge P4 - Abdoof

View as PDF

Submit solution

Points: 7
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

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 1 \le W \le 100 words. Each word has 1 \le L \le 200 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


  • 0
    richardyi25  commented on April 18, 2016, 9:13 p.m.

    Can you add the number of words W as the first line so it is solvable in Turing?


    • 2
      aurpine  commented on April 18, 2016, 9:22 p.m. edit 2

      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)


      • 2
        richardyi25  commented on April 18, 2016, 10:44 p.m.

        Thanks for responding and informing me about eof!


  • 0
    Anix55  commented on Feb. 24, 2016, 6:11 p.m.

    should our program be case sensitive?


    • 0
      Zander  commented on Feb. 24, 2016, 6:23 p.m.

      the case doesn't matter


      • 0
        Anix55  commented on Feb. 24, 2016, 6:25 p.m.

        thanks


  • 2
    jimgao  commented on Dec. 30, 2015, 1:52 p.m.

    In the output specifications, it is instructed that we output

    not valid

    if the string is not valid. However, in the second sample output, the output was

    invalid

    for the given string


    • 2
      cheesecake  commented on Dec. 30, 2015, 1:58 p.m.

      Thank you for noticing. The problem statement has been corrected.


    • 1
      r3mark  commented on Dec. 30, 2015, 1:56 p.m.

      It should be invalid (I outputted invalid and got AC).