Problem 117: Incitatus
(U.M. ACM Runoffs 2003, problem 4)
Description
President Dubya has appointed his favourite horse, Francis,
to the Supreme Court. Now Francis has to be confirmed by
the senate, and in order to succeed, he must impress the
senators with his answers to their questions.
Fortunately, in the tradition of trained horses, Francis
can perform simple arithmetical operations and indicate
the answer by stamping his foot the right number of times.
Each stamp of his foot produces a "clop" sound, so if
a senator asks Francis "what is two plus two", the response
will be "clop clop clop clop". Francis has been taught to
respond with a "Neigh!" to questions he can not answer.
The senators are permitted to ask Francis questions in
any of these three forms:
What is A and B
What is A plus B
What are A and B
where A and B may be replaced by any of the
words
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight, or
Nine.
If the question asked by a senator exactly matches one of the allowed forms,
the response must be the right number of clops, each separated from the next by a space,
and terminated by a full-stop or period. If the question does not exactly match
one of those forms, the response must be "Neigh!". You must write a program
that predicts exactly what Fracis will "say" for any given question.
Input Format
The input will be a sequence of questions, each occupying a whole single
line. Each line of input represents a separate question. The input is
not case sensitive, and words may be preceeded or followed by any number
of spaces, but there will be no additional characters in a correct
question. The end of the input is marked by a line beginning with the
word "stop", which should not be responded to.
Output Format
For each line of input (except the "stop" line) produce exactly one
line of output. If the input matches a valid form of question, the output
must be the correct number of "clop"s separated by single spaces and terminated
with a full stop. If the input does not match a valid form, the output
should be the word "Neigh!" eactly as shown, with capital N and exclamation mark.
Limits
No input line will exceed 1000 characters in length.
Sample Input
what is six and three
what are two and two
What are Two AND Two
what are two and two, Francis
what is three plus two
what are three plus two
hello Francis
what is one and one?
stop
Sample Output
clop clop clop clop clop clop clop clop clop.
clop clop clop clop.
clop clop clop clop.
Neigh!
clop clop clop clop clop.
Neigh!
Neigh!
Neigh!
End of Problem