Algorithms and Data Structures

Encoding a sentence

When talking to a friend of yours, you’d like to encode your messages so that other people don’t understand them. You get together with your friend Alice and decide to send messages to each other after following a secret algorithm that you came up with. Given an English sentence, you’ve decided to shift all the consonant letters (B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Z) cyclically, while leaving all the vowels untouched. You hope that this will prevent other people from reading your conversations. Yet, encoding and decoding the messages every time yourself is tedious. So, you decide to implement the algorithm to make sure the messages get encoded instantly.


The input contains the text of English letters, whitespaces, and punctuation marks. The length of the text does not exceed 100,000.


The program should print the encoded text.


Hello, how are you doing?
lelho, wor ade you noigH?


Time limit: 0.2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue