The Curious Case of the Colored Balls
Easy+10 XP · +5 Aurabasicsstringscounting
Rohan is playing with a box of colorful balls. He has collected balls of different colors: Red, Green, and Blue. He wants to know how many balls of each color he has. Can you help him count them?
Input
A single line containing a string S consisting of characters 'R', 'G', and 'B', representing the colors of the balls.
Output
Print three space-separated integers: the count of 'R' balls, the count of 'G' balls, and the count of 'B' balls.
Constraints
1 <= length of S <= 1000
Time limit 1 s (native code; slower languages get more)Memory 256 MB15 hidden tests
Example 1
Input
RGRGRB
Output
3 2 1
There are 3 Red balls, 2 Green balls, and 1 Blue ball.
Example 2
Input
BBG
Output
0 1 2
There are 0 Red balls, 1 Green ball, and 2 Blue balls.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
RGRGRB
Example 2 input
BBG