program CodeCup;

{
  Example of a Lucky Words player program for the CodeCup.

  This only demonstrates how to do the input and output. You will
  have to write the algorithms for the game all by yourself.
}


{ This procedure reads the list of words. }
procedure ReadWordList;
var
	f: Text;
	word: String;
begin
	Assign(f, 'words.dat');
	Reset(f);
	while not Eof(f) do begin
		ReadLn(f, word);
		{ TODO : store the word in some sort of list }
	end;
	Close(f);
end;


{ This procedure makes the game board empty. }
procedure InitGameBoard;
begin
	{ TODO }
end;


{ This procedure selects the best possible letter and the position
  where we want to put it. }
procedure PickLetterAndPosition(var letter: Char; var pos: Integer);
begin
	{ TODO }
end;


{ This function returns the best possible position for an opponent letter. }
function PickPosition(letter: Char): Integer;
begin
	{ TODO }
end;


{ This procedure stores a letter at a position on the game board. }
procedure PutLetterAtPosition(letter: Char; pos: Integer);
begin
	{ TODO }
end;


{ This function returns the total number of wordpoints on the game board. }
function CountTotalWordpoints: Integer;
begin
	{ TODO }
end;


{ Main program }
var
	line: String;
	letter: Char;
	pos: Integer;
	myturn: Boolean;
	m: Integer;

begin
	{ Read the list of words }
	ReadWordList;

	{ Make the game board empty }
	InitGameBoard;

	{ Read the starting letter }
	ReadLn(letter);
	PutLetterAtPosition(letter, 24);

	{ Find out who will move first }
	ReadLn(line);
	if line = 'start' then begin
		myturn := True;
	end
	else begin
		myturn := False;
		letter := line[1];
	end;

	{ Do all moves }
	for m := 1 to 48 do begin

		if myturn then begin

			{ It's my turn to pick a letter }
			PickLetterAndPosition(letter, pos);
			PutLetterAtPosition(letter, pos);

			{ Write output }
			WriteLn(letter);
			WriteLn(pos);
			Flush(Output);

			{ Next turn }
			myturn := False;

		end
		else begin

			{ My opponent has picked a letter }
			if m > 1 then
				ReadLn(letter);

			{ Pick a position for the letter }
			pos := PickPosition(letter);
			PutLetterAtPosition(letter, pos);

			{ Write output }
			WriteLn(pos);
			Flush(Output);

			{ Next turn }
			myturn := True;

		end;

	end;

	{ NIO contestants : Output total nr of wordpoints }
	WriteLn(CountTotalWordpoints);
	Flush(Output);

end.


syntax highlighted by Code2HTML, v. 0.9.1