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.
Deadline expired on 17 October 2005.