Caesar Cipher

Encrypt a string by rotating each English letter by a signed shift. Uppercase and lowercase letters stay in their original case; digits, spaces, and…

Encrypt a string by rotating each English letter by a signed shift. Uppercase and lowercase letters stay in their original case; digits, spaces, and punctuation stay unchanged. The text and shift are separate arguments. Return one exact string.

- `text` has 0 to 40 printable ASCII characters (U+0020 through U+007E). - `-1000 <= shift <= 1000`, and shift is an exact integer. - Booleans, non-integers, control characters, and non-ASCII characters are invalid. - Rotate only `A`–`Z` and `a`–`z`; preserve every other printable character.

Example 1: input text = "XYZ", shift = 1; output "YZA". Uppercase letters wrap from Z back to A.

Example 2: input text = "xyz", shift = 2; output "zab". Lowercase letters wrap while preserving case.

Example 3: input text = "Hi, 42!", shift = 3; output "Kl, 42!". Letters rotate; the space, digits, comma, and exclamation mark remain unchanged.

Category: Strings. Topic: strings. Difficulty: Easy. Patterns: string-processing.