CCC '11 S1 - English or French?

View as PDF

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

Problem type
Canadian Computing Competition: 2011 Stage 1, Senior #1

You would like to do some experiments in natural language processing. Natural language processing (NLP) involves using machines to recognize human languages.

Your first idea is to write a program that can distinguish English text from French text.

After some analysis, you have concluded that a very reasonable way of distinguishing these two languages is to compare the occurrences of the letters t and T to the occurrences of the letters s and S. Specifically:

• if the given text has more t and T characters than s and S characters, we will say that it is (probably) English text;
• if the given text has more s and S characters than t and T characters, we will say that it is (probably) French text;
• if the number of t and T characters is the same as the number of s and S characters, we will say that it is (probably) French text.

Input Specification

The input will contain the number followed by lines of text, where each line has at least one character and no more than characters.

Output Specification

Your output will be one line. This line will either consist of the word English (indicating the text is probably English) or French (indicating the text is probably French).

Sample Input 1

3
The red cat sat on the mat.
Why are you so sad cat?
Don't ask that.

Output for Sample Input 1

English

Sample Input 2

3
Lorsque j'avais six ans j'ai vu, une fois,
une magnifique image,
dans un livre

Output for Sample Input 2

French

(Note: Sample Input 2 is the first sentence of Le Petit Prince by Antoine de Saint-Exupéry.)

Sample Input 3

4
Si je discernais ta voix encore
Connaissant ce coeur qui doute,
Tu me dirais de tirer un trait
Quoi que partir me coute.

Output for Sample Input 3

English

(Note: Sample Input 3 is added by DMOJ from Le Fantôme de l'Opéra.)

• commented on April 16, 2022, 3:22 p.m.

Make sure you remember to check for capital letters as well!

• commented on Dec. 17, 2021, 7:06 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on May 5, 2022, 2:23 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Jan. 25, 2022, 5:50 a.m.

Ok, but for what is the integer? it does not make any sense. im getting a wrong answer just on one test, if u could take a look at my code and say in what im messing it, i would be grateful. Thanks bro.

• commented on Jan. 25, 2022, 12:57 p.m.

The number represents the number of lines of text. Your code fails because it only looks at the first one.

• commented on Dec. 25, 2018, 4:47 p.m.

I speak french, and t actually works at guessing the language! Cool problem!