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

Problem I. 316. (March 2013)

I. 316. Elementary statements of a logical expression are denoted by uppercase letters of the English alphabet. A logical expression may contain the not, and, or and the implication operations, denoted by the characters !, &, | and >, respectively. Parentheses are used modify the precedence, if necessary.

Your program should illustrate the evaluation of such expressions in the following way. First, choose one part of the expression that is among the expressions to be evaluated first, and denote it by a lowercase letter of the English alphabet. Then substitute this letter into the original expression, and repeat the above procedure over and over again. At the end, we obtain only one lowercase letter of the English alphabet.

The only line of the input file contains the logical expression to be processed, with a maximal length of 80 characters. Successive lines of the output file should show the steps of the evaluation process. Each line consists of 2 parts: the first part begins with a still unused lowercase letter of the English alphabet, then an equality sign should be displayed, finally, a subexpression to be evaluated first is shown. The second part comes after a space character: the original expression should be rewritten so that the subexpression to be evaluated has been replaced by the actual lower case letter.

The table shows some inputs (``Bemenet'') and the corresponding outputs (``Kimenet'').

The first and second command line arguments to your program should be the name of the input and output files, respectively.

The source code (i316.pas, i316.cpp, ...) together with a short documentation (i316.txt, i316.pdf, ...) - also describing which developer environment to use for compiling, further a brief description of your solution - should be submitted.

(10 pont)

Deadline expired on April 10, 2013.


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

A logikai kifejezések kezelését váró program meglepően nehéznek bizonyult.

A legtöbb beküldő nem nézett utána, hogy a logikai kifejezések kiértékelése hogyan történik. A logikai műveletek prioritása a következő sorrendben növekszik: ekvivalencia, implikáció, vagy, és, tagadás. Az azonos prioritású műveleteket balról jobbra haladva kell feldolgozni.

Az értékelésnél az alábbi tesztfájlt használtuk: teszt316.zip

A dokumentáció tartalmi része; az előírásoknak megfelelően működő program; az 1-6 esetből legalább kettő helyes; az 1-6 esetből legalább mind helyes; a 7-12 esetből legalább kettő helyes; a 7-12 esetből legalább mind helyes; a többi teszteset 1-1 pontot ért.

Versenyzői észrevétel érkezett, hogy a bemeneti fájlokban az első sor végén található sorvégjel miatt ad hibás eredményt a programja. (A feladatban "első és egyetlen sor" megfogalmazás szerepelt.) Ezért a megoldásokat a sorvégjel nélküli tesztesetekkel teszt316b.zip is megvizsgáltuk, mivel a megoldás tartalmilag ilyekor is lehet helyes.

Az eredmények ennek megfelelően módosultak.

Az összes tesztesetre csak Fényes Balázs programja adott helyes választ: i316fenyes.cs


Statistics:

7 students sent a solution.
9 points:Fényes Balázs.
7 points:2 students.
3 points:2 students.
2 points:1 student.
1 point:1 student.

Problems in Information Technology of KöMaL, March 2013