You are here : InfyTQ Archive >> InfyTQ Coding Problems
Consider a string, group the similar characters in combinations. Then, concatenate first element and last element alternatively.
Consider a non empty string instr, and print a string outstr using below mentioned logic:
- Find the sum of ASCII value of all the characters present in instr.
- If sum is an Armstrong number of order n, remove duplicate characters present in the string instr and assign the updated instr to outstr. Perform case-sensitive comparison of characters while removing the duplicate characters.
- A number with n digits is said to be an Armstrong number of order n if the sum of its digits each raised to the power of n is equal to the number i.e
a^4+b^4+c^4+d^4 = abcd
- A number with n digits is said to be an Armstrong number of order n if the sum of its digits each raised to the power of n is equal to the number i.e
- If the sum is not an Armstrong Number of order n, print -1
Input
First line contains instr,
Output
Print outstr or -1 accordingly to the standard output stream.
Sample Input 1
BANaA
Sample Output 1
BANa
Sample Input 2
Van
Sample Output 2
-1
