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
legrand:
2012-11-24 08:18:43
@Jander: I know my algo can't be shorten to 100B more. For the settings line ending problem see my submission 8116134 (SIGSEGV) where I don't use a gets() to clean the settings line ending.
|
|
Jander:
2012-11-23 09:52:02
@legrand - Line endings are all "\012" aka "\n". My code is based upon your 8070679 submission, and still uses exactly the same input methods.
|
|
legrand:
2012-11-23 09:01:11
My 789 codelength solution is still obsfurcated. To shorten more, I need to know more the input format: the end of the settings line is not \n nor \n\r and it requires extra-code. Also the end of steckerbrett line is unknown and there is room for shortening here. Last edit: 2012-11-23 09:21:58 |
|
Jander:
2012-11-23 07:28:33
@Aditya - That code still has whitespace in it :-) The actual code size is 577 bytes, I just haven't posted that one yet.
|
|
Jander:
2012-11-16 21:33:50
@Aditya Pande - Not any more it isn't. Although, I think there is opportunity for significant improvement in all the C/C++ solutions. There is a lot of complexity that can still be removed/simplified. Last edit: 2012-11-16 21:35:07 |
|
Aditya Pande:
2012-11-15 09:05:51
@Jander :thanks
|
|
Jander:
2012-11-14 12:43:35
@Aditya Pande - Check how your code behaves with multiple test cases in a single run. Your code isn't cleaning up properly between each case. |
|
Aditya Pande:
2012-11-12 07:45:39
@problemsetter plz give more test cases or tell me why my submission 8036036 fails and gets WA
|
|
Jander:
2012-10-19 10:38:48
@legrand - as I'd already commented this challenge was aimed at SHORTEN from the outset. I figured that I'd open it to main Spoj to allow those that don't normally enter the SHORTEN arena a chance at something different.
|
|
legrand:
2012-10-19 10:00:57
I think putting the problem in shorten contest don't simplify the machine as in challenge to reduce the code we made obsfurcated one, and there will be perl or awk submissions. |
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 |