Imperative French

View as PDF

Submit solution

Points: 15
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

French is hard for many. Imperative, as a tense in French, in its affirmative form, have different rules for pronouns than other tenses. You have significant trouble dealing with this special form. Your French teacher had some pity for you and allowed you to bring a program to a quiz to help you. Your program must convert a sentence from present tense, in the affirmative, to imperative. You are only allowed to interact with the program under the supervision of the teacher, so you have to rely only on it to pass French. You are allowed to look up exactly how imperative is formed when you write your program.

French Imperative Rules

In the present tense, a sentence is formed like this: <subject> [pronouns [pronouns ...]] <verb>, for example: Tu me le promets. Tu is the subject, me and le are pronouns, promets is the conjugated form of promettre. In the imperative, the word order is different: <verb>-[pronoun[-pronouns...]] ! For example: Promets-le-moi ! Promets is the same, conjugated verb, and le and moi are the pronouns. Notice the subject is dropped.

Note: if the infinitive of the verb ends in -er, and the subject is tu, the final -s, if any, of the conjugated verb is dropped in the imperative. Also, me and te in the imperative becomes moi and toi. The pronouns le, la, me, te, moi, toi also contracts with the next word if it starts with a vowel (a, e, i, o, u, y), in both present and imperative. Therefore, you would say "Tu m'aimes", not *"Tu me aimes."

Present Tense Pronoun Order
First Second Third Fourth Fifth
me
te
nous
vous
le
la
les
lui
leur
y en
Imperative Pronoun Order
First Second Third Fourth
le
la
les
moi
toi
nous
vous
lui
leur
y en

Input Specification

The first line will be N, the number of lines to process.

Each line will contain a verb in the infinitive V, and a sentence S, in the format V: S. The sentence is composed of a subject, pronouns, and a verb. There will be no objects after the verb. The verb is guaranteed to be regular if it ends in -er. The input doesn't have to semantically make any sense, only correct pronoun placement is guaranteed. Note: When l' is encountered, assume it's le contracted always, not la.

Output Specification

Output the imperative form of every line in the input.

Sample Input

1
promettre: Tu me le promets.

Sample Output

Promets-le-moi !

Comments


  • 4
    kevinyang  commented on March 18, 2020, 12:20 a.m. edited

    I took like a long time to solve this and there's some incorrect test data in this question. Not sure if it was intentional. One of the inputs in present tense was tu cede instead of tu cedes. Another test case that I saw was Tu me oublies which should be tu m'oublies. Please fix so others who try to solve this problem won't waste time searching for a nonexistent error in their code.


    • 0
      GeeTranzit  commented on March 19, 2020, 4:02 a.m. edited

      the final -s, if any, of the conjugated verb is dropped in the imperative

      I think that implies that the -s could appear. Should be made more clear.


  • 1
    aeternalis1  commented on Aug. 16, 2017, 3:02 a.m. edit 3

    If there are multiple pronouns from the same group (in terms of ordering post-transition), in what order are they placed in the imperative sentence? Does it not matter or are they placed in the order in which they were inputted?

    Another question: In the case of an input such as 'aller: Tu y vas.', should the output be 'Vas-y !' or 'Va-y !'? (as a french student this concerns me) EDIT: Apparently it didn't matter in these test cases.


    • 4
      quantum  commented on Oct. 6, 2017, 7:48 a.m.

      In case you are wondering...

      The verb is guaranteed to be regular if it ends in -er.

      And aller is not very regular.


  • 1
    moladan123  commented on Dec. 14, 2014, 2:18 a.m.

    The funny thing is, I just learned about this rule in french class.


  • 0
    cfc  commented on Dec. 7, 2014, 1:56 a.m.

    How many test cases are there supposed to be? Also, is it case sensitive? and picky about the punctuation?


    • 0
      quantum  commented on Dec. 7, 2014, 2:41 a.m.

      There is one test case with around 50 lines, case- and punctuation-sensitive, following the sample format. Hope this clears up the confusion.