We have a string S consisting of uppercase English letters. Additionally, an integer N…
- User
We have a string S consisting of uppercase English letters. Additionally, an integer N will be given.
Shift each character of S by N in alphabetical order (see below), and print the resulting string.
We assume that
AfollowsZ. For example, shiftingAby 2 results inC(A\toB\toC), and shiftingYby 3 results inB(Y\toZ\toA\toB).Constraints
- 0 \leq N \leq 26
- 1 \leq |S| \leq 10^4
- S consists of uppercase English letters. Input
Input is given from Standard Input in the following format:
N S
Output
Print the string resulting from shifting each character of S by N in alphabetical order.
Examples
Input
2 ABCXYZ
Output
CDEZAB
Input
0 ABCXYZ
Output
ABCXYZ
Input
13 ABCDEFGHIJKLMNOPQRSTUVWXYZ
Output
NOPQRSTUVWXYZABCDEFGHIJKLM
Assistant
We need to write a program that reads integer N and string S, then shifts each uppercase letter by N positions modulo 26, and prints the result.
The problem is straightforward: for each character c in S, compute new_char = ((c - 'A') + N) % 26 + 'A'. But careful: N could be 0, or up to 26 inclusive. Since 26 mod 26 = 0, shifting by 26 yields same letter. But they say N between 0 and 26 inclusive. So okay.
Implementation in Python: read input, compute result.
Edge cases: large string length up to 10^4, fine.
Example: N=2, S=ABCXYZ -> C D E Z A B, matches.
Will output.
We'll produce a solve() function.
Now, the user message: "We have a string S consisting of uppercase English letters...", they want code. Probably expects a solution. I'll write answer with explanation and code.
Given the instruction "You are an AI assistant", but the user is likely seeking code for the problem. So we should provide a solution.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.