Mathematical and Physical Journal
for High Schools
Issued by the MATFUND Foundation
 Already signed up? New to KöMaL?

Problem I. 204. (January 2009)

I. 204. As we have seen in Problem I. 201. in our last Issue, the Cardan grille can be used to encode messages. Write a program that encodes a given text using a given grille, that is, produces a suitable arrangement of letters of the text according to the grille.

The structure of the grille in its initial position is read from a text file being the first command line argument of your program. If the size of the grille is N×N, then this file has N lines: each line consists of o'' or .'' characters. The o'' symbol represents a hole'': letters under these squares are visible. The original text is read from a text file specified by the second command line argument. This file (having one or more lines) can contain lowercase and uppercase letters of the Hungarian alphabet, further space characters and the usual punctuation marks. The output of your program should be a text file given in the third command line argument. This file should contain blocks of N×N letters, separated by empty lines.

Encoding starts from the beginning of the text, and successively creates blocks of N×N letters. These blocks can contain letters only from the original text, but converted into uppercase characters. Spaces, newline characters and other punctuation marks should not be included. Note that the encrypted text could be decoded easily if the last block of letters is incomplete (due to the fact that the original text has ended). To avoid this problem, you should copy the appropriate number of letters from the beginning of the text and attach these to the end of the text so that the last block of letters becomes complete.

In the example, Első fájl (a rács)'' means First file (grille)'', Második fájl (a szöveg)'' means Second file (original text)'', while Harmadik fájl (a titkos)'' is Third file (encoded)''.

The source code of your program (i204.pas, i204.cpp, ...) together with a short documentation (i204.txt, i204.pdf, ...) should be submitted, also containing a brief description of your solution and the name of the developer environment to use for compiling.

(10 pont)

Deadline expired on February 16, 2009.

Sorry, the solution is available only in Hungarian. Google translation

A feladat megoldása az alábbi FreePascal környezetben készült, érthetően kommentezett programból nyomon követhető (i204.pas).

A megoldásokat a mellékelt tömörített állományban található bemenetekkel teszteltük, emellett a kapott a kimeneteket is közreadjuk. (teszt.zip).

Statistics:

 14 students sent a solution. 10 points: Englert Péter, Fehér Péter, Kővágó Zoltán. 9 points: Barta 111 János, Erdős Gergely, Jákli Gábor, Tóth Szabolcs. 8 points: 1 student. 7 points: 1 student. 6 points: 1 student. 5 points: 3 students. 3 points: 1 student.

Problems in Information Technology of KöMaL, January 2009