ENIGMAS - Enigma Machine
This challenge is to simulate the three rotor M3 Enigma Machine. For each test three lines of information will be provided; the first line will contain the rotor settings, the second the plugboard, and the third will be the text to encode/decode with the Enigma cipher.
Input
The first line will contain a single value T, for the number of tests to follow, where T <= 100.
For each test there will be three lines:
- The first line will contain three entries indiciating: the Walzenlage, the Ringstellung, and the Grundstellung in the form '123 AAA BBB'. The Walzenlage only contains numbers 1-5. The Ringstellung and Grundstellung will be provided as triplets of letters in the range A-Z.
- The second line will contain pairs of letters, from the range A-Z, indicating the settings for the Steckerbrett - there may be up to 13 pairs of letters.
- The final line of the test will contain an unknown length message to encode/decode - the message will be in the standard quintuple form used at the time, separated with spaces, eg 'ABCDE FGHIJ KL'. The final group may be 1-5 letters in length. Again, only the range of letters A-Z will be used. The line will be terminated in a newline ('0x0A').
The Enigma machine used is the three rotor M3 version. This had five rotors, of which only three would have been installed at any time. The Umkehrwalze in use is the 'B' wiring.
Output
The output is to match the third line of the input, i.e. must be in the same quintuple grouping. One line of output per message is to be produced.
Example
Input:2123 JAN DER2 123 JAN DER SP OJ RU LZ THISX ISXAN XEXAM PLEXI NPUT 543 SPO JPL SH OR TE NI YUQKD YVPSF HCQEI VHAPE NAQZQ ISP OJ RU LZYUQKD YVPSF HCQEI VHAPE NAQZQ IOutput:
SJLKM SVZYM HXTUW VVWYY EDEB THISX ISXAX DECOD XEDXM ESSAG E
hide comments
dltbg:
2020-06-06 06:47:14
why did i get WA (submission 26100652) when submitted the exact same code (submission 26099107) that has been accepted?
|
|
Jander:
2013-01-31 16:52:31
@mostafa_36a2 - Glad you're enjoying it. With time you'll find that the Enigma is a remarkably simple machine that doesn't take much to implement.
|
|
Mostafa 36a2:
2013-01-30 11:23:20
Thank you for this problem ..
|
|
Jander:
2012-12-16 08:55:39
@Aditya - the C solution I've got is 518. My Perl one is 418, so yes you can go smaller. I'd stick with the C one for the moment and really look at what the Enigma process goes through before changing languages. |
|
Aditya Pande:
2012-12-14 13:12:46
i should switch to perl perhaps?
|
|
Jander:
2012-11-30 19:54:45
@Aditya - Technically there is only one Enigma algorithm - there are however many implementations :-)
|
|
Aditya Pande:
2012-11-26 03:20:42
@Jander my algo seems to take me only so far
|
|
Jander:
2012-11-25 13:08:33
@Aditya / @Legrand - New target of 520 B. Last edit: 2012-11-30 19:55:01 |
|
legrand:
2012-11-25 09:26:32
@Jander - I have shorten it to 704 but I think I can't do more with that algo. |
|
Jander:
2012-11-24 17:18:32
@Legrand - So, you can't shorten by more than 100B eh ? 822 -> 715 = 107 bytes removed :-) Last edit: 2012-11-24 17:18:45 |
Added by: | Jander |
Date: | 2012-10-04 |
Time limit: | 10s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | http://en.wikipedia.org/wiki/Enigma_machine |