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
andT
characters thans
andS
characters, we will say that it is (probably) English text; - if the given text has more
s
andS
characters thant
andT
characters, we will say that it is (probably) French text; - if the number of
t
andT
characters is the same as the number ofs
andS
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.)
Comments
Can you check whats wrong with my submission, this works in vscode but here its full of error
First take n as int(input()), then take each line of input, say x,
for _ in range
of n. Then instead of n[i], you should put x[i].Guys what’s wrong with my code:
Hi Pycode, I recently completed this problem and took a look at your code and was able to fix it and make it work.
I don't want to solve the problem for you but I can give you a couple hints to fix your code.
On your latest submission:
Review line 6, when I run your code it errors out. I think you accidentally put in some parentheses that should be removed.
Lines 7 and Lines 9 are missing == on one side, can you see where its missing?
You could also simplify your final IF Elif Else to just an If and Else.
https://dmoj.ca/problem/ccc11s1/resubmit/6680660
The URL doesn't go anywhere. Maybe it's easier to go to the discord and ask for help there! https://discordapp.com/invite/EgJVpxz
Can someone help me with my submission. https://dmoj.ca/submission/6507888
I failed the last test case.
Hello! I see you got it to work, but I was very confused about one detail-- it seems your successful submission takes #s == #t and outputs as English, when the problem specifies that it should output as French in that instance. I think you found a way to trick the judgement! I'm very new at this (just getting this far in the Zingaro book) but I believe your code only accepts two lines of input, and won't process any additional lines? E.g. in Sample Input 1, the code only reads through "The red cat sat on the mat." And determines French or English based solely on that one line.
english or spanish
chinese
who ever moves first is g-
So, if your input is: '1 English' then the output must be: 'French'
It's really sad that if the check of your code is good, depends on whether you first check French instead of English.
hi, this is my code below but only 7 cases work, may i know what's wrong with my code?
https://dmoj.ca/submission/6266541
You only take input for the first line, as the text variable only inputs over one line. Try using the test cases first before asking for help. So when you input the text, you only get the first line.
Could anyone take a look at my submission? It passed all of my local tests and matches the required output exactly. The funny thing is, when I remove the part of the code which prints English for when numbers of S and T are equal it passes.
Edit: NVM I am blind and thought it said English (It was French)