-
Notifications
You must be signed in to change notification settings - Fork 6
/
Holes_Codechef.cpp
37 lines (32 loc) · 1.12 KB
/
Holes_Codechef.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
Chef wrote some text on a piece of paper and now he wants to know how many holes are in the text.
What is a hole? If you think of the paper as the plane and a letter as a curve on the plane, then each letter divides the plane into regions.
For example letters "A", "D", "O", "P", "R" divide the plane into two regions so we say these letters each have one hole.
Similarly, letter "B" has two holes and letters such as "C", "E", "F", "K" have no holes.
We say that the number of holes in the text is equal to the total number of holes in the letters of the text.
Help Chef to determine how many holes are in the text.
*/
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
string a;
cin>>a;
int ctr=0;
for(int i=0;i<a.length();i++){
switch(a[i]){
case 'B' : ctr+=2;break;
case 'D' : ctr+=1;break;
case 'O' : ctr+=1;break;
case 'P' : ctr+=1;break;
case 'Q' : ctr+=1;break;
case 'A' : ctr+=1;break;
case 'R' : ctr+=1;break;
}
}
cout<<ctr<<endl;
}
return 0;
}