Roughly 15 to 20 minutes, reading time inclusive
You are required to make a substitution cipher solver which solves the key of a given substitution cipher, assuming you don't know the uncrypted text, in reasonable time.
In cryptography, a substitution cipher is a one-to-one translation of characters a-z for an unencrypted text, where the translation mapping is specified by a key.
For example, if the key is "phqgiumeaylnofdxjkrcvstzwb", it means "a"->"p", "b"->"h", and so on.
Unencrypted text: defend the east wall of the castle
Encrypted text: giuifg cei iprc tpnn du cei qprcni
Clone the materials needed for the exercise at:
https://github.com/laichunpongben/coding-interview
In decrypted.txt
. When you solve the problem, you assume you don't know this. For your reference only.
In encrypted.txt
. This is after applying the cipher.
In vocab.txt
. These are the words which come from the uncrypted text, sorted by alphabetical order and delimited by whitespace.
In descending significance:
- How you approach and solve the problem. Even psuedo-code or skeleton code can be material.
- Coding style
- Interaction with the peer (that's the interviewer, if any)
- Level of completion. However, don't feel discouraged if you cannot finish the solver.
- Use your own PC (or interviewer's PC), and your choice of programming language and development environment.
- Get help from googling/stackoverflow etc. But please don't directly search for "How to make a substitution cipher" or copy codes from GitHub etc. Remember, the purpose of this exercise is to evaluate YOUR skills.
- Discuss with the interviewer, if any. Think aloud may help.
- Ask the interviewer to shut up/leave, if you find him/her disturbing.
- Ask for wifi access, if necessary
Good luck and happy coding!