Problem description. Chef decides to distribute fancy stationary among kids. Chef has…
- User
Problem description. Chef decides to distribute fancy stationary among kids. Chef has collection of erasers and pencils . Each kid needs to be given a pencil and eraser. Your job is to help find Chef how many kids can get the stationary and how many min pencils or erasers the chef will need to clear the stock that is left with him. Input Input description.
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. Each test case contains string made up of E and P.
Output Output description.
For each test case, output a single line containing the number of kids he can give, no of min pencils or erasers needed.
Constraints
1 ≤ T ≤ 1000 String made up of E and P
Example Input: 2 EPPEP EPPPPEE
Output: 2 1 3 1
Explaination CASE 1: there are 2 erasers and 3 pencils. so chef can only give stationary to 2 students. For remaining 1 pencil he will need 1 more eraser to clear the stock
Assistant
T = int(input()) for _ in range(T): s = input().strip() e = s.count('E') p = s.count('P') kids = min(e, p) remaining_e = e - kids remaining_p = p - kids diff = abs(remaining_e - remaining_p) print(kids, diff)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.