-4
I need to write a program in Python that counts the amount of "holes" in a string. Imagine, for example, that the letters "A", "D", "O", "P", "R" have only one hole. Similarly, the letter "B" has two holes. The letters "C", "E", "F", "K" have no holes. The program should consider that the number of holes in a text is equal to the total number of holes in the letters of the text. The user must provide in the input two information, in two lines: The first line contains a single integer T <= 40 which indicates the number of test cases. Then follow-up T test cases. Each line of the test case contains a non-empty text composed only of uppercase characters of the English alphabet. The size of each text is less than 100. For each test case, the output consists of a line containing the number of holes found in the test case. If the entrees are:
3
LARANJA
UVA
PERA
The exit would be:
4
1
3
I haven’t tried any promising code yet. I need a hint.
Have you thought about how to start developing? At least the initial steps?
– Leonardo Coelho
@Diegof was right, I had not seen it. But, if I were him, I would remove both the beginning of the question and the tag, since it is a question about algorithm. It would be a beginning to ask the question to be better received.
– Pablo Almeida
I thought of assigning a value to each relevant letter, that is, those that have "holes", according to the number of "holes" that it has. The provided string would be read by the program, passing through each letter and counting the values of each one and adding up at the end. My difficulty is in managing the functions in the right way.
– Guilherme Santana De Souza
@Diegof In this type of question, in which the AP wants a "north" (as it was written in the original question), marked with the algorithm tag, I don’t see how the language is relevant. It restricts and decreases the possibility of him finding an answer. Who has the hidden Python tag does not see this question, even being able to answer.
– Pablo Almeida
It’s not that I see the problem. I only see room for improvement, both to increase the visibility of the question and for future readers who have the same doubt. But OK. :)
– Pablo Almeida