#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'anagram' function below.
#
# The function is expected to return an INTEGER.
# The function accepts STRING s as parameter.
#
from collections import Counter
def anagram(s):
n=len(s)
if n%2==0:
sub1=s[:n//2]
sub2=s[n//2:]
a=Counter(sub1)
b=Counter(sub2)
return sum((a-b).values())
return -1
# Write your code here
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
q = int(input().strip())
for q_itr in range(q):
s = input()
result = anagram(s)
fptr.write(str(result) + '\n')
fptr.close()
Comments
Post a Comment