FunctionRacerProblemsRace

Mirror Cipher

BeginnerStringsPython, JavaScript, TypeScript, Java, C++

Encode text with the mirror cipher:

Return the encoded string. Encoding an encoded string gives the original text back.

Example 1

text "abc"
returns "zyx"

a, b, c sit at positions 1, 2, 3 from the front, so they become the letters 1, 2, 3 from the back: z, y, x.

Example 2

text "Hello, World 2024!"
returns "Svool, Dliow 7975!"

H mirrors to S, e to v, l to o, o to l; the digits 2, 0, 2, 4 mirror to 7, 9, 7, 5; the comma, space and ! stay.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Strings problems