The Good and the Bad
InterviewTime limit1sMemory limit128 MB
Count the letters g and b in each hero name, ignoring case, and print whether the name is GOOD, A BADDY, or NEUTRAL.
- Level
Easy1 of 10
- Topics
- String, Implementation, Brute force
- Solved
- No attempts yet
Problem
Bikini Bottom is teeming with superheroes who have superpowers. SpongeBob and Patrick want to decide, from a hero's name alone, whether that hero is one of the good guys or one of the baddies.
- SpongeBob: Wow, I can feel great power in this name! But I can't tell whether it belongs to a good guy or a bad guy.
- Patrick: Easy. Just count the letter 'g' and the letter 'b' in the name. More 'g' than 'b' means a good guy; more 'b' than 'g' means a baddy. Look at the mighty hero 'Algorithm Crunching Man' — it has two 'g's and no 'b'.
- SpongeBob: Oh, I see. So 'Green Lantern' is good and 'Boba Fett' is a baddy?
- Patrick: Correct! And letters are case-insensitive: count 'G' as 'g' and 'B' as 'b'.
- SpongeBob: Then what about 'Superman'?
- Patrick: He has no 'g' and no 'b', so the counts are equal — he's neutral.
- SpongeBob: Ah, so even when there are zero 'g's and zero 'b's, equal counts mean neutral.
- Patrick: Right. Let's go through the names one by one.
- SpongeBob: Do we really have to count all of these ourselves all day?
- Patrick: Then let's hand it to the human who's been eavesdropping on us. Do a good job and I'll buy you a Krabby Patty.
Help SpongeBob and Patrick decide whether each hero is good or bad.
Rules:
- Let be the number of 'g'/'G' in the name and the number of 'b'/'B'.
- If , the hero is good (
GOOD). - If , the hero is a baddy (
A BADDY). - If (including when both are 0), the hero is neutral (
NEUTRAL).
Input
The first line contains the number of test cases ().
Each of the next lines contains one hero name. Each name has at least 1 character and at most 25 characters.
Names consist only of uppercase and lowercase English letters and spaces. Spaces separate the words of a multi-word name.
Output
For each name, print one line: the hero's name exactly as given, followed by a single space and is.
Then print GOOD, A BADDY, or NEUTRAL according to the counts of 'g' and 'b' in the name. In other words, each line has the form <name> is <verdict>.