I. 157. Regular readers of this Journal may remember our great detective, Watson from Problem I. 134. Those bad guys begin to sense that their business is endangered, so from now they encrypt their messages. Watson wants to prevent further robberies, therefore he should be able to decrypt their messages and encrypt his own ones. Encrypted messages contain only numbers separated by semicolons. Watson also knows that every message is signed by one of the wrongdoers. For example, the sequence
119; 25; 125; 69; 80; 118; 67; 147; 43; 21; 109; 29; 88; 128; 130; 72; 58; 156;
belongs to Hack Er. However, signatures are polymorphic, so
112; 32; 36; 158; 63; 135; 97; 117; 44; 20; 51; 87; 58; 158; 49; 153; 83; 131;
is also Hack Er's signature.
Your task is to find out how the gangster's encryption scheme works, then write a program to help Watson decode existing and encode new messages. Your program has three parameters, the first is either ``de'' or ``en'' (meaning decoding or encoding), the second parameter is the name of the file to read, while the third parameter is the name of the converted message file, as in the following example: i157 de secret.txt plaintext.txt.
The source code of your program (i157.pas, i157.cpp, ) should be submitted.
Deadline expired on 15 May 2007.
Google Translation (Sorry, the solution is published in Hungarian only.)
Ha jól emlékszem, régen tettem közzé C++ megoldást, legyen akkor most ez:
Véges Márton, (Budapest, Fazekas Mihály Gimnázium) megoldása: