xaviers-challenge

Xavier asks his friend to perform a particular task.The task is to find out the ASCII value of each character of a given STRING and then add them up to find the weight of the given string as 'W',now after finding out the weight his task is to divide the weight of string W with the length of string 'L'such that the final answer is 'F' rounded of to previous integer value in case of float or double value.

Now Xavier introduces a twist in the tail the twist seems to be as follows:-

1.If 'F' is odd then to needs to find out reverse of the given string.For eg:- if 'F'
  is 109 and input string is xyzabc the output must be cbazyx.

2.If 'F' is even then print the original string.

INPUT

First line inputs the no of test cases T.

Second line inputs the string on which the task is to be performed.

OUTPUT

T no of outputs according to the above task.

Constraints

T ≤ 100.
L ≤ 100.

SAMPLE INPUT
1
xyzabc

SAMPLE OUTPUT
cbazyx

Explanation

The input string is "xyzabc"
then,

The ASCII value of x is 120. 

The ASCII value of y is 121.

The ASCII value of z is 122.

The ASCII value of a is 97.

The ASCII value of b is 98.

The ASCII value of c is 99.

W=657.

F=109.

So output="cbazyx".

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
b = input()
a = input()
l = len(a)
#print(l)
count = 0
for i in a:
	count += ord(i)
count1 = count // l
if(count1%2==0):
	print(a)
else:
	print((a[::-1]))


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'

n = int(input())
for i in range(n):
	tc = list(input())
	# tc = [x for x in tc if x != ' ']
	ans = 0
	for j in tc:
		ans += ord(j)
	
	ans /= len(tc)
	
	if ans % 2 == 0:
		print(''.join(tc))
	else:
		print(''.join(tc[::-1]))


from math import floor
def process(s):
	t=0
	for i in range(len(s)):
		t+=ord(s[i])
	x=floor(t/len(s))
	if x%2!=0:
		print(s[::-1])
	else:
		print(s)
t=int(eval(input()))
while t>0:
	s=input()
	process(s)
	t=t-1


test=eval(input())
a=0
for i in range (test):
	str=input()
	for x in str:
		a+=ord(x)
	b=a/len(str)
	if b%2!=0:
		print(str[::-1])
	else:
		print(str)


if __name__=='__main__':
	T = int(input())
	for i in range(0,T):
		string = input()
		sum1 = 0
		for i in string:
			sum1 += ord(i)
			
		if (sum1//len(string)) % 2 ==0:
			print(string)
		else:
			print(string[::-1])


t=int(input())
while(t):
	s=str(input())
	l=list(s)
	z=len(s)
	l=list([ord(x) for x in l])
	a=sum(l)
	b=a//z
	if(b%2==0):
		print(s)
	else:print(s[::-1])
	t-=1


for _ in range(eval(input())):
	m = [ ]
	s = input()
	k = [ord(c) for c in s]
	z = sum(k)
	f = z / len(s) 
	if ( f % 2 == 0):
		print(s)
	else:
		m = s[::-1]
		print("".join(m))


t=int(input())
for i in range(0,t):
	s=input()
	l=list(s)
	l.reverse()
	f=0
	for k in range(0,len(s)):
		f=f+ord(s[k])
	res=f//len(s)
	if(res%2==0):
		print(s)
	else:
		out=""
		for h in range(0,len(s)):
			out=out+l[h]
		print(out)


T=eval(input())
for i in range(T):
	a=input()
	W=sum(ord(ch) for ch in a)
	F=W//len(a)
	if F%2==0:
		print(a)
	else:
		a=a[::-1]
		print(a)



def reversed_string(a_string):
	return a_string[::-1]
t = eval(input())
for T in range(0,t):
	str = input()
	w = 0
	c = 0
	for c in range(len(str)) :	
		w = w + ord(str[c])
	f = w / len(str)
	if f % 2 == 0 :
		print(str)
	else:
		print(reversed_string(str))


t=eval(input())
for i in range(0,t):
	s=input()
	w=0
	for j in range(0,len(s)):
		w+=ord(s[j])
	f= int(w/len(s))
	if f%2==0:
		print(s)
	else:
		print(s[::-1])


# Read input from stdin and provide input before running code

import string
T = int(input())
for i in range(T):
	string = input()
	W = 0
	for letter in  string:
		W+= ord(letter)
	L = len(string)
	F = W/L
	if F%2!=0:
		string = string[::-1]
		print(string)
	elif F%2 ==0:
		print(string)



for _ in range(int(input())):
	s=input()
	d = len(s)
	r = 0
	for i in range(len(s)):
		r += ord(s[i])
	r /= d
	if r%2 != 0:
		print(s[::-1])
	else:
		print(s)


t=eval(input())
for _ in range(t):
	a=input()
	w=0
	for i in range(len(a)):
		w+=ord(a[i])
	f=w/len(a)
	if f%2!=0:
		print(a[::-1])
	else:
		print(a)