Check a password, then encrypt it
A password is valid if it has at least 8 characters, a digit, an uppercase letter, a lowercase letter and a special character (anything that is not a letter or digit). If it is not valid, print Error!. Otherwise shift every letter and digit forward by N places, wrapping around (Z → A, z → a, 9 → 0), leave other characters as they are, and print the result.
Reported in: TCS NQT (8 May 2024) (memory-based)
Input
First line: the password. Second line: N.
Output
The encrypted password, or Error!
Constraints
1 ≤ length ≤ 100; 1 ≤ N ≤ 25; no spaces.
Example 1
Input:
T@nuJ@in13
2
Output:
V@pwL@kp35Example 2
Input:
password1
3
Output:
Error!Example 3
Input:
Ab#12345
25
Output:
Za#67890Hint: Check each rule with a flag while scanning the string. To shift a letter, work with its position in the alphabet modulo 26; for a digit, modulo 10.