Mathematical and Physical Journal
for High Schools
Issued by the MATFUND Foundation
Already signed up?
New to KöMaL?
I want the old design back!!! :-)

Problem I. 109. (September 2005)

I. 109. Write a program to play the following game. The user enters ``head'' or ``tail'' in every step, which your program should guess in advance. The program should also make a statistics of its scores.

More precisely, the program reads the user's choice from the standard input, being a single letter H or T followed by an Enter. Then the program prints in one line its guess made beforehand, further, the number of its correct and incorrect guesses so far. The game is aborted by the user.

The program should make a record of the user's habits and make its decisions accordingly: the program should collect that -- depending on the last two steps and the program's guesses (being altogether 16 cases) -- heads or tails were entered more often by the user. (For example, if the user entered heads in the last two steps and the computer guessed them both correctly, then the program should examine the user's reaction in previous such situations whether heads or tails were selected more often.) If a given situation did not happen previously, or the user selected the same number of heads and tails, then the computer should guess randomly.

Example (messages from the computer are in italics):

The source code of your program (i109.pas, i109.c, ...) should be submitted.

(10 pont)

Deadline expired on October 17, 2005.

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

Megoldás. Egy lehetséges Pascal program letölthető innen.


31 students sent a solution.
10 points:Balambér Dávid, Gilián Zoltán, Gombos Gergely, Györök Péter, Hunyady Márton, Kacz Krisztián, Kovács 129 Péter, Ozsvárt László, Szentandrási István, Szoldatics András, Szolnoki Lénárd, Véges Márton, Vincze János.
8 points:8 students.
6 points:1 student.
5 points:1 student.
4 points:2 students.
2 points:3 students.
0 point:3 students.

Problems in Information Technology of KöMaL, September 2005