UVa 10058 - Jimmi's Riddles

10058 - Jimmy's Riddles

 * http://acm.uva.es/p/v100/10058.html

Summary
Match the statement against this grammar: STATEMENT = ACTION | STATEMENT, ACTION ACTION = ACTIVE_LIST VERB ACTIVE_LIST ACTIVE_LIST = ACTOR | ACTIVE_LIST and ACTOR ACTOR = NOUN | ARTICLE NOUN ARTICLE = a | the NOUN = tom | jerry | goofy | mickey | jimmy | dog | cat | mouse VERB = hate | love | know | like | VERBs

Gotchas

 * VERB can be post-fixed by any number of 's' characters.
 * Do not copy and paste the output statement. The ASCII code for the apostrophe is different.

Implementations
Java users can have a simple solution (about 20 LOCs) by constructing a regular expression based on the grammar given. Sample Java implementation:

Input
the dog and a cat know goofy jimmy kills tom goofy hate mouse jerry tom hates jerry, jimmy hates tom

Output
YES I WILL NO I WON'T NO I WON'T YES I WILL

Categories here, use the form , see Categories for a list