Vlad and the Best of Five (Codeforces 1926A)
Tags: Implement, implementation

Vladislav has a string of length $$$5$$$, whose characters are each either $$$\texttt{A}$$$ or $$$\texttt{B}$$$.Which letter appears most frequently: $$$\texttt{A}$$$ or $$$\texttt{B}$$$?

Input: The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 32$$$) — the number of test cases.The only line of each test case contains a string of length $$$5$$$ consisting of letters $$$\texttt{A}$$$ and $$$\texttt{B}$$$.All $$$t$$$ strings in a test are different (distinct).

Output: For each test case, output one letter ($$$\texttt{A}$$$ or $$$\texttt{B}$$$) denoting the character that appears most frequently in the string.


Sample Inputs:
8
ABABB
ABABA
BBBAB
AAAAA
BBBBB
BABAA
AAAAB
BAAAA

Sample Outputs:
B
A
B
A
B
A
A
A

Solution (Python):
testcases = int(input())
for _ in range(testcases):
    s = input()
    count_a = 0
    count_b = 0
    for i in range(len(s)):
        if s[i] == 'A':
            count_a += 1
        elif s[i] == 'B':
            count_b += 1
    if count_a > count_b:
        print('A')
    else:
        print('B')

Solution (Python):
nn = int(input())
for i in range(nn):
    ss = input()
    print('A' if ss.count('A') > ss.count('B') else 'B')

Solution (Python):
import copy
import math

def solve():
    s = input()
    j = 0
    for i in s:
        if i == 'A':
            j += 1
    if j < 3:
        print('B')
    else:
        print('A')
s = int(input())
while s:
    s -= 1
    solve()