| The Banana Traffic Gang
Statement
Goal
Story:You are a CIA agent investigating on banana traffic.
You infiltrated the network of this dangerous organisation. However, all their messages are encrypted...
Hopefully, your contact just told you they used affine cipher. He gave you the key to decipher everything.
Now, it's your turn agent !
_______________________________________________________________________________
Challenge:
Let's associate each letter of the alphabet (whether it's a capital letter or not) with a number so that we have: A corresponds to 0, B to 1, C to 2, D to 3... Z to 25.
For example, "helLo" becomes 7 4 11 11 14
To encrypt a string using an affine cypher algorithm, we use the formula:
y = (
with:
- x which corresponds to the letters from the string we have to encrypt
- y which corresponds to the encrypted letters of the string
-
With this process, if
If
You can only decrypt strings if 26 and
You'll be given an encrypted string and the keys.
Print "error" if the keys aren't valid.
Else, decipher the message and print it in upper cases letters.
tip: a letter is always coded the same
Good luck agent !
Input
Line 1: a an integer, the first key
Line 2: b an integer, the second key
Line 3: msg the string you have to decrypt.
Line 2: b an integer, the second key
Line 3: msg the string you have to decrypt.
Output
"error" if the keys aren't valid
else the deciphered message in uppercase letters
else the deciphered message in uppercase letters
Constraints
0<a<64
0<b<128
1 ≤ length of msg ≤ 127
0<b<128
1 ≤ length of msg ≤ 127
Example
Input
5 8 NIVIVI
Output
BANANA
Game modes
Fastest, Shortest
Test cases
BANANA Test
Input
5
8
NIVIVI
Output
BANANA
banana plane Validator
Input
11
1
B KSBOT RAZNSI BGGLYT CZDZGGZJ JLCA BSS CAT MBOBOBR JT ZGITGTI
Output
A PLANE SHOULD ARRIVE TOMORROW WITH ALL THE BANANAS WE ORDERED
kiwii dealers Test
Input
41
4
u dfury YUWUU XMENMZO NGIEDMX SO... TM IEZMBSN
Output
I THINK KIWII DEALERS LOCATED US... BE CAREFUL
bananas shouldn't be on pizza Validator
Input
3
100
krm FWVIF peb ZWJWJWY uj gq PUTTW ?
Output
WHO DARED PUT BANANAS IN MY PIZZA ?
kiwii dealers hacking attempt Test
Input
52
47
ARE YOU KIWIING ME ? THIS CRYPTER THING JUST DOESN'T WORK AT ALL..
Output
error
trainee used computer Validator
Input
2
23
NH tZL FFVZNF JLF Z HFZV ZXXXXX XXD XDD H, NJ ZFBZVFH XXXXXH !
Output
error
banana dealer Test
Input
7
9
PLLM PL NW MGL GJYQDTY JM 2KP. N'II GJAL 42BZ DS QJWJWJF HNMG PL !
Output
MEET ME IN THE HARBOUR AT 2PM. I'LL HAVE 42KG OF BANANAS WITH ME !
banana joke Validator
Input
17
19
IZN XAAJW ZN MJWL TO-OJJYZGR... 69HR XA KTGTGTN AXW XGYL 420 JVWXN... ZE NIXVYS BXNE 690 JVWXN !
Output
HIS OFFER IS VERY AP-PEELING... 69KG OF BANANAS FOR ONLY 420 EUROS... IT SHOULD COST 690 EUROS !
Solution language
Solution
Stub generator input