You're a young detective. Every detective needs a function to decrypt a vigenère cipher. It's a modification of a caesar cipher.
Let's talk more about the algorithm:
- Every letter is a number. A=0, B=1, C=2, (...), Z=26
- Output should be presented in capital letters.
- Use ONLY letters. Without interpunction, spaces, etc
- Function has two arguments: encrypted text and key (both are strings). Your output will present a decrypted text. Let's show it on easy example from http://en.algoritmy.net/article/45623/Vigenere-cipher
Ciphertext : CTMCCD, Key : Cat
C – C = 2 – 2 = 0 = A
T – A = 19 – 0 = 19 = T
M – T = 12 – 19 = 19 = T
C – C = 2 – 2 = 0 = A
C – A = 2 – 0 = 2 = C
D – T = 3 – 19 = 10 = K
decrypted word: ATTACK
It's quite simple,right? Good luck!
Solution Stats
Problem Comments
6 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers29
Suggested Problems
-
21488 Solvers
-
Back to basics 3 - Temp Directory
386 Solvers
-
910 Solvers
-
Return elements unique to either input
812 Solvers
-
Check if number exists in vector
14272 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
you should add a test case like GrantII does in his 'divisible by X' problems...
http://www.mathworks.com/matlabcentral/cody/problems/42408-divisible-by-6
thanks for advice! done! :)
Your testsuite is still incomplete. I recommend you to include cases where Ciphertext and Key both contain upper and lower case letters
Please kindly note that your test case 3 (a='az' b='za' y_correct='zz') is wrong. If you re-score all solutions, I think none of them would pass this test case. However, you may need to re-score multiple times because ind = randi(3) does not necessarily yield ind = 3.
thanks, I missed that mistake. it should be ok right now.
"A=0, B=1, C=2, (...), Z=26"
Shouldn't Z be 25?