Skip to content

Instantly share code, notes, and snippets.

@Akshay-2001
Forked from sai-sondarkar/Golden Project B4 FCS
Created September 3, 2020 08:43
Show Gist options
  • Save Akshay-2001/b85b51ed0893a76f7af6d77f648dc8f4 to your computer and use it in GitHub Desktop.
Save Akshay-2001/b85b51ed0893a76f7af6d77f648dc8f4 to your computer and use it in GitHub Desktop.
Panda has recently learned about ASCII values.He is very fond of experimenting. With his knowledge of ASCII values and character he has developed a special word and named it Panda's Magical word.
A word which consist of alphabets whose ASCII values is a prime number is an Dhananjay's Magical word. An alphabet is Panda's Magical alphabet if its ASCII value is prime.
Dhananjay's nature is to boast about the things he know or have learnt about. So just to defame his friends he gives few string to his friends and ask them to convert it to Panda's Magical word. None of his friends would like to get insulted. Help them to convert the given strings to Dhananjay's Magical Word.
Rules for converting:
1.Each character should be replaced by the nearest Panda's Magical alphabet.
2.If the character is equidistant with 2 Magical alphabets. The one with lower ASCII value will be considered as its replacement.
Input format:
First line of input contains an integer T number of test cases. Each test case contains an integer N (denoting the length of the string) and a string S.
Output Format:
For each test case, print Panda's Magical Word in a new line.
Constraints:
1 <= T <= 100
1 <= |S| <= 500
SAMPLE INPUT
1
6
AFREEN
SAMPLE OUTPUT
CGSCCO
Explanation
ASCII values of alphabets in AFREEN are 65, 70, 82, 69 ,69 and 78 respectively which are converted to
CGSCCO with ASCII values 67, 71, 83, 67, 67, 79 respectively. All such ASCII values are prime numbers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment