## CCC '11 S1 - English or French?

View as PDF

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

Problem type

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.)

• sankeeth_ganeswaran  commented on Feb. 10, 2019, 10:47 a.m.

I'm not sure what's wrong with my code, I failed test case 3. Can someone help?

• AlanL  commented on Feb. 10, 2019, 11:38 a.m. edited

I don't see anything wrong with your actual code. I believe that the problem is that right after you have scanner.nextInt(), when you use scanner.nextLine() it actually reads the same line of the integer, meaning it would read nothing. So just use an extra scanner.nextLine() in between your reading of "a" and your lines, and don't use it. That hopefully should fix the problem.

• NeverDrinkAndDerive1  commented on Dec. 25, 2018, 11:47 a.m.

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

• AmineHamoura  commented on Dec. 21, 2017, 10:32 a.m.

I think that my submission is totaly true but i got just 40, any help or idea about what's going wrong please?!

• ZippIE  commented on Dec. 21, 2017, 12:09 p.m.

if the given text has more t and T characters than s and S characters

Your program only counts then individually

• AmineHamoura  commented on Dec. 21, 2017, 2:16 p.m.

i do not just count but i've compared the caracters between them too?

• Lunazoul  commented on Oct. 23, 2017, 6:03 p.m.

I dont see how i could get test case 3 wrong. Its just a simple comparison...

• injust  commented on Oct. 23, 2017, 7:47 p.m.

Try rereading the problem statement, especially the classification criteria.

• Lunazoul  commented on Oct. 24, 2017, 5:57 p.m.

The problem was that i had an int scanner before a String

• Asuna_Orz  commented on March 20, 2016, 4:49 p.m.

I'm not sure bout why I got wrong on Test Case 1...

• FatalEagle  commented on March 20, 2016, 6:48 p.m.

Either use StringBuilder or process each line as you read it. Concatenating all the lines takes time.