Submission
# | When | Author | Problem | Language | CPU | Memory | |
---|---|---|---|---|---|---|---|
20836 | 2024-06-09 09:17:55 | AHAMMED_99 | Akash and Cipher | Python 2 | 13 ms | 7320 kb | Runtime Error - 1 |
Source Code
def decrypt_message(n, s, q): result = "" for i in range(n): shift = i + 1 if q[i] == 'U' else -(i + 1) char_code = ord(s[i]) + shift if char_code < ord('a'): char_code += 26 elif char_code > ord('z'): char_code -= 26 result += chr(char_code) return result # Read input T = int(input()) for _ in range(T): n = int(input()) s = input() q = input() # Decrypt the message and print the result print(decrypt_message(n, s, q))