#K94872. Deterministic Password Generator
Deterministic Password Generator
Deterministic Password Generator
You are given an integer N representing the desired length of a password. Your task is to generate a deterministic password of length N that satisfies the following conditions:
- The password must contain at least one lowercase letter.
- The password must contain at least one uppercase letter.
- The password must contain at least one digit.
To make the output deterministic for the same input, use the following algorithm:
- Let the first character be
chr((N % 26) + 97)
(a lowercase letter). - Let the second character be
chr(((N+1) % 26) + 65)
(an uppercase letter). - Let the third character be
str((N+2) % 10)
(a digit). - For every index i from 3 to N-1 (0-indexed), append a character chosen as follows:
- If i is even, choose
chr(((N+i) % 26) + 97)
(lowercase letter). - If i is odd, choose
chr(((N+i) % 26) + 65)
(uppercase letter).
- If i is even, choose
- Reverse the entire sequence of characters and output the result.
If the input N is not in the range \(3 \le N \le 100\), then output ERROR
.
Note: This algorithm ensures that the same input always produces the same password.
inputFormat
The input consists of a single integer N (\(3 \le N \le 100\)).
outputFormat
Output a single string which is the generated password if N is valid, or output ERROR
if N is outside the allowed range.
3
5Ed