You are on page 1of 3

It was vacation time and Alice and Bob were getting bored.

Alice and Bob decide to play a game. Alice says any random Number X and
bob have to say what will be its twin prime. If twin prime is not possible for the
given number than bob must say NO. Twin primes are the numbers having a
difference of 2. So help bob to win the game.
Example
Input 1:
3
Output 1:
5
Input 2
1232
Output
NO

You are a very good hacker and have recently joined RAW. Your team has
found some secret encrypted details of ISIS and has managed to find out that
how the message was encrypted.

The algorithm of encryption is as follows:

1. The message is an integer which is encrypted and a string is formed.


2. The integer is converted to its corresponding binary.
3. Groups of 4 bits each are made from the least significant bit. (if the last
group doesn’t have 4 bits, then zeros are added before MSB to
complete a group of 4.)
4. All these groups of 4 bits are converted back to integers separately.
5. Instead of writing the integers, corresponding alphabets are written.
(0->a, 1->b, 2->c, 3->d, 4->e, 5->f, 6->g, 7->h, 8->i, 9->j)

Your task is to convert all these encrypted strings back to the integers.

Input Format:
The first line of input contains a single integer t denoting the number of test
cases.
Next t lines contain a single string each denoting the encrypted message.
(It is guaranteed that all the characters in the string will be lower case
alphabets from “a” to “j”)
Output Format:
Decrypt the string and print the integer in a new line for each test case.

Sample Input:
1
fh
eb
Output:
87
65

Explanation:
Test case 1:
f->5, h->7 ; 5->0101, 7->0111
fh -> 0101,0111
or fh -> 1010111
1010111 -> 87
Hence fh -> 87

Write a Python Script that takes a string as user input (with empty prompt) and
strips out all characters except: a-z, A-Z, 0-9, underscore and the forward
slash.
Alphabets can be Lower or Upper Case.

All other characters are to get removed and replaced by underscore.

In the replaced version, no consecutive multiple underscores should exist.

No underscores for trailing or leading white spaces.


For example,

Input:- "Ab 4/5 (t) "


Output:- "Ab_4/5_t_"
Input:- "AB___cd@# E"
Ouput:- "AB_cd_E"

You might also like