# Imperfections dans mon français

To conjugate a verb in l'imparfait, one needs to perform the following steps:

1. Find the "stem" of the word; this is achieved by omitting the -ons from the nous-conjugated form of the word. For example, vivre is nous vivons; removing -ons from vivons yields viv-.
2. Take the stem and add an appropriate ending, according to the subject. Here are the endings:

je         -ais
tu         -ais
il/elle    -ait

nous       -ions
vous       -iez
ils/elles  -aient


Objective Given a verb and a subject, output the imperfect form of that verb with respect to the subject. The input format can be in any format convenient to your language. Your submission can either be a program, snippet, or function. (Note that the verb does not have to be a real verb.)

You can assume that the verb is a regular verb, i.e, items like avoir would be treated as an -ir verb, not an irregular one. The only verb you have to quantify as irregular is être; it is conjugated as such:

j'étais
tu étais
il/elle était

nous étions
vous étiez
ils/elles étaient


Here are the conjugations for -er, -re, and -ir verbs in the nous forms

-ER => (e)ons           ; e is added after a 'g'
-RE => ons
-IR => issons


Anything that does not end with such does not have to be handled.

(Note that je merges with the next vowel, if there is one. E.g., je acheter -> j'achetais. h will be considered a vowel for our purposes.)

# Example IOs

input: tu vivre
output: tu vivais

input: elles nager
output: elles nageaient

input: je morter
output: je mortais     ; incorrect in real life, but correct for our purposes

input: vous finir
output: vous finissiez

input: il croire
output: il croiait

input: nous jouer
output: nous jouions


# Bonuses

• -5N bytes for all N extra irregular verb handled.
• -10% if you also output every conjugation of the verb in the imperfect tense.

This is a , so the shortest program in bytes wins.

• @CᴏɴᴏʀO'Bʀɪᴇɴ Does je habiter become j' habite or j'habite? – Cows quack Oct 23 '15 at 15:48
• @KritixiLithos Either is fine. – Conor O'Brien Oct 23 '15 at 16:02
• @CᴏɴᴏʀO'Bʀɪᴇɴ For the -10% bonus, does the input still need to have the pronoun, or can it just be the verb? – Cows quack Oct 23 '15 at 17:16
• Morter doesn't exist, I assume you are referring to to die which is mourir, which would yield je mourais which is actually correct. – Fatalize Nov 9 '16 at 9:18
• @Fatalize I was referring to morter. It's technically incorrect because its not a word. – Conor O'Brien Nov 9 '16 at 13:18

# Processing, 342-10%(bonus) = 307.8

I have created a function. To call the function, include the pronoun as the first parameter and the verb as the second. For example, a("je","habiter")

Please note that my program conjugates the verb for all the pronouns, so that is how I got the 10% bonus.

void a(String a,String b){String[]e={"ais","ais","ait","ait","ions","iez","aient","aient"},p={"je","tu","il","elle","nous","vous","ils","elles"};if("aehiou".contains(b.charAt(0)+""))p[0]="j'";for(String i:p)println(i+" "+b.substring(0,b.length()-2)+(b.endsWith("ger")?"e":b.endsWith("ir")?"iss":"")+e[java.util.Arrays.asList(p).indexOf(i)]);}


void a(String a,String b){
String[]e={"ais","ais","ait","ait","ions","iez","aient","aient"},p={"je","tu","il","elle","nous","vous","ils","elles"};
if("aehiou".contains(b.charAt(0)+""))p[0]="j'";
for(String i:p)
println(i+" "+b.substring(0,b.length()-2)+(b.endsWith("ger")?"e":b.endsWith("ir")?"iss":"")+e[java.util.Arrays.asList(p).indexOf(i)]);
}


Output (for a("je", "habiter"))

j' habitais
tu habitais
il habitait
elle habitait
nous habitions
vous habitiez
ils habitaient
elles habitaient

• Congratulations! – Conor O'Brien Oct 25 '15 at 16:01
• Yes! Yes! Yes! My first victory in code-golf! Yes! Yes! [clears throat] @CᴏɴᴏʀO'Bʀɪᴇɴ Thank you. – Cows quack Oct 25 '15 at 17:22

s#v=m++g++d++t
where
m|v=="être"="ét"|i/="rio"&&i/="erd"&&i/="eri"=r 2 v|otherwise=r 3 v
d|init i=="ri"="iss"|i=="eri"="y"|otherwise=""
t|s=="je"||s=="tu"="ais"|elem s["il","elle","on"]="ait"|s=="nous"="ions"|s=="vous"="iez"|s=="ils"||s=="elles"="aient"
r i=reverse.drop i.reverse
i=take 3\$reverse v


You can compile this in ghci and use it like so "je"#"choisir" to get "choisissais".

This code works with some irregular verbs. It can conjugate croire (je croyais, tu croyais…) or prendre as well as all its derivatives (apprendre, comprendre, etc.).

I couldn't find a short way to conjugate other verbs ending in -ire (such as lire, rire, dire, etc.) or in -dre (such as craindre, soudre, etc.).

• Shouldn't it be 352 bytes because of the ê and é? – Cows quack Oct 23 '15 at 14:56

# Java, 389385383382352.7 443-10%(bonus) = 398.7 bytes

Byte count reduced thanks to @PeterTaylor and @Fatalize
Please note that my program conjugates the verb for all the pronouns, so that is how I got the 10% bonus.

class A{public static void main(String[]a){String[]e={"ais","ais","ait","ait","ions","iez","aient","aient"},p={"je","tu","il","elle","nous","vous","ils","elles"},w=new java.util.Scanner(System.in).nextLine().split(" ");if("aehiou".contains(w[1].charAt(0)+""))p[0]="j'";for(String i:p)System.out.println(i+" "+w[1].substring(0,w[1].length()-2)+(w[1].endsWith("ger")?"e":w[1].endsWith("ir")?"iss":"")+e[java.util.Arrays.asList(p).indexOf(i)]);}}


 1| class A{
2|   public static void main(String[]a){
3|     String[]e={"ais","ais","ait","ait","ions","iez","aient","aient"};
4|     String[]p={"je","tu","il","elle","nous","vous","ils","elles"};
5|     String[]w=new java.util.Scanner(System.in).nextLine().split(" ");
6|     if("aehiou".contains(w[1].charAt(0)+""))p[0]="j'";
7|     for(String i: p) {
8|       System.out.print(i+" "+w[1].substring(0,w[1].length()-2)+(w[1].endsWith("ger")?"e":w[1].endsWith("ir")?"iss":"")+e[java.util.Arrays.asList(p).indexOf(i)]);
9|     }
10|   }
11| }


Explanation:

Lines 3-4: Initialisation of arrays.
Line    5: Read a line as input and split it into words
Line    6: Shorten the je to j' in presence of a succeeding vowel or a h.
Line    7: Create a for-loop iterating through all of the pronouns .
Line    8: Conjugate the verb(remove the ending from the infinite form of the verb and add ending accordingly) and print the result, along with the pronoun.


## (Old Version) 393-10% = 352.7 bytes

Please note also that my old program does not obey with the new rule about the je merging into j'.

class A{public static void main(String[]a){String[]e={"ais","ais","ait","ait","ions","iez","aient","aient"},p={"je","tu","il","elle","nous","vous","ils","elles"},w=new java.util.Scanner(System.in).nextLine().split(" ");for(String i:p)System.out.println(i+" "+w[1].substring(0,w[1].length()-2)+(w[1].endsWith("ger")?"e":w[1].endsWith("ir")?"iss":"")+e[java.util.Arrays.asList(p).indexOf(i)]);}}

• Why do you have both k and l? – Peter Taylor Oct 22 '15 at 20:19
• @PeterTaylor Gee, thanks for spotting that one! – Cows quack Oct 23 '15 at 4:01
• You have a useless space here: w[1].substring(0, w[1].length()-2) – Fatalize Oct 23 '15 at 11:54
• @Fatalize I have removed the useless space in my latest edit. – Cows quack Oct 23 '15 at 14:52

# Python 3, 258-10% = 232.2 223-10% = 200.7

Huge thanks to @WW for saving me 35 bytes!

def t(x,y):
z=y[-2:];y=y[:-2];y+='e'*(y[-1]=='g');y+='iss'*(z=='ir')
return[('j'+"e'"[y[0]in'aeiouh']+' tu il elle nous vous ils elles').split()[i]+' '+y+'ais ais ait ait ions iez aient aient'.split()[i]for i in range(8)]


Try it online!

• You can use a split to compress your lists a little more. Also using ; can help you to avoid some of the indentation. – Sriotchilism O'Zaic Jul 18 '18 at 5:35
• You also don't need parens around your conditionals in the ifs. – Sriotchilism O'Zaic Jul 18 '18 at 5:39
• Your submission seems to put a space after j', which doesn't seem to match the spec. – Sriotchilism O'Zaic Jul 18 '18 at 5:48
• @WW Thanks! and in the comments of the main post the OP says "j' " with a space is fine – JathOsh Jul 18 '18 at 6:02
• In that case here's a shorter version – Sriotchilism O'Zaic Jul 18 '18 at 6:03