CCC '11 S1 - English or French?

View as PDF

Submit solution

Points: 5 (partial)
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 N (0 < N < 10\,000) followed by N lines of text, where each line has at least one character and no more than 100 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.)


Comments


  • -1
    kristanto777777  commented on Jan. 17, 2026, 9:41 a.m.

    The DMOJ added testcase is so bad the editor had to clarify he didn't write it💀💀💀


  • 1
    Math_competition_pro_  commented on Jan. 15, 2026, 1:24 a.m.

    bro i misspelled english into engilsh 😭


  • 1
    rocket  commented on Nov. 5, 2025, 3:31 a.m. edited

    if you're stuck, you can combine all the lines into one single massive string and running it through a method that counts the separate amounts of s and ts (since spaces dont matter), hope this helps!


  • 1
    SMARTER_BoB  commented on May 21, 2025, 2:42 a.m.

    For some reason, you have to set the # of t's > the # of s's in the if loop. If you do it the other way around, then it marks the first case wrong.


  • 0
    valerie_aveni_1  commented on March 22, 2025, 5:52 p.m.

    Why does sample input three output English when it's clearly French?


    • 0
      4EVr_Working  commented on March 23, 2025, 6:43 p.m.

      It's because even though the language is French, but it fits the question's criteria for English.

      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 you count the number of t and Ts compared to the number of s and Ss in Sample Input 3, you find this:

      Number of s (uppercase and lowercase): 6

      Number of t (uppercase and lowercase): 9

      Since the number of occurrences of t is greater than the number of occurrences of s, then we should deem it English.

      (Just to clarify to anyone else who might've gotten confused)


  • 15
    anonymous69  commented on June 18, 2024, 1:18 p.m.

    english or spanish


    • -1
      rfasta  commented on July 3, 2024, 11:54 a.m. edited

      both


    • 4
      htoshiro  commented on June 20, 2024, 11:08 a.m.

      who ever moves first is g-


      • 0
        Jules830  commented on Dec. 18, 2024, 6:52 p.m.

        *stops breathing and blinking for the rest of my coding class


  • 5
    AlexOldest  commented on May 17, 2024, 9:10 a.m. edited

    So, if your input is: '1 English' then the output must be: 'French'


  • 0
    Ruard000000000000  commented on March 31, 2024, 9:30 a.m.

    It's really sad that if the check of your code is good, depends on whether you first check French instead of English.