Azad is first-year engineering student. one day his teacher caught him playing game on his phone during data structures lecture then teacher gave him a problem and ask him to come tomorrow with solution otherwise he will not allow him to attend the lecture and as Azad’s attendance is already below the required attendance, so he can not afford to miss upcoming lectures.
Azad is not good at programming so he is asking you to help him to solve a problem given below.
By using lower case character from a to z you have to form a string of length N (1 ≤ N≤ 100) using following instructions.
When N is even:
Use N/2 (when N ≤ 26) number of sequence characters or character from starting and ending part of a to z .
For example N= 2 az
When N is greater than 26 repeat the instructions again. For example N= 28 abcdefghijklmnopqrstuvwxyzaz
When N is odd:
Use (N-1)/2 (when N ≤ 26) number of sequence characters or character from starting and ending part of a to z and to select the middle character use case 1 and case 2.
Case 1- when sum of digits or digit of N is equal to even Give preference to those characters whose ASCII value is smaller to select the middle character of string.
for example N=11 ( 1+1= 2 is even)
abcdefvwxyz is correct
abcdeuvwxyz is incorrect
Case 2- when sum of digits or digit of N is equal to odd Give preference to those characters whose ASCII value is greater to select the middle character of string.
for example N=21 ( 2+1= 3 is odd)
abcdefghijpqrstuvwxyz is correct
abcdefghijkqrstuvwxyz is incorrect
When N is greater than 26 repeat the instructions again . For example N= 29 abcdefghijklmnopqrstuvwxyzayz
• The first line of the input contains a single integer T denoting the number of test cases.
• The first line of each test case contains N denoting length of the string.
For each test case, output the required string of length N in new line.
1 ≤ T ≤ 100
1 ≤ N≤ 100
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.