Cracking Vigenère: unknown language
Description:
Background
Codewars nation is at war with a mysterious enemy. You are leading the security department responsible for intercepting and interpreting their communications.
Unfortunately, their language is unknown and the linguists in your department are unable to start understanding it because the enemy is also encrypting its messages.
You task is to decrypt the messages, so that the linguists can start working on deciphering the language itself.
Starting assumptions
But you are not completely in the dark! Your spies have discovered a few key facts which might help to decrypt the messages:
- The enemy language uses the English alphabet: all messages will always use the basic 26 letters in the English alphabet, in upper case
- The messages contain no spaces or punctuation
- They are encrypting the messages with a Vigenère cipher (more detail below) but the key used is different for every message
- There are 100 messages to decrypt in total and the enemy is gradually learning that longer keys are harder to crack:
- there will be 30 keys of length 2
- then there will be 30 keys with length 5
- finally there will be 40 keys of lengths varying between 6 and 11
- The enemy is planning an attack on the Codewars Headquarters and all the messages will be on the topic of that attack: therefore, every message will contain the string 'CODEWARS HEADQUARTERS' somewhere
Vigenère Cipher
The Vigenère cipher is too long to fully explain here. If you are unfamiliar, you could read the Wikipedia page or some other tutorial. There are also two other Kata which might be worth looking at before attempting this one.
- Cracking the Vigenère cipher, step 1: determining key length
- Vigenère Cipher Helper
- Breaking the Vigenère Cipher
Task
To complete this Kata you need to define a function which can be applied to each of the 100 enemy messages and return the encryption key used for each one.
Note: The enemy language is randomly generated each time you submit a solution. The sample sizes have been set high enough that strong solutions should pass all 100 tests the vast majority of the time. However, if your solution fails one or two tests, then you may want to re-submit. Your linguists can deal with minor inaccuracies anyway.
Similar Kata:
Stats:
Created | Apr 23, 2021 |
Published | Apr 25, 2021 |
Warriors Trained | 26 |
Total Skips | 1 |
Total Code Submissions | 247 |
Total Times Completed | 7 |
Python Completions | 7 |
Total Stars | 2 |
% of votes with a positive feedback rating | 25% of 2 |
Total "Very Satisfied" Votes | 0 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 3 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 5 kyu |