Contents

Interactive Problems

They are problems of special type. While with usual ones you shoud process input and submit the answer once - with these new tasks you instead are involved in a kind of game against server.

Simplest of these problems is Say 100 - it is recommended to start with.

It is easier to think of such problems as of turn-based games. You send requests to server informing it of your moves and it responds with its moves until you either win or lose.

Technical details

  1. For "playing" such games we use separate server, use address http://codeabbey-games.atwebpages.com/GAME-NAME.php. (don't miss .php ending and http prefix, not "https" for now).
  2. You should send your requests via HTTP using POST method. Request data should be in plain text.
  3. Since the game is played at different server, we use tokens to identify you and to prove your success.
  4. You will get authentication token as usual input data for the problem. This token should be sent along with all requests while "playing".
  5. If at the end it appeared that you win the game, you receive an victory token. Put it as the answer for the problem and submit.

Here is an article Post Request in Python on sending POST requests from Python which may be helpful. However there are many examples for every language offered by google. I hope to add some more examples by and by.

Responses and requests are sent as a plain text. Each line describes some value. The name (and meaning) for this value is specified at the beginning of the line and is separated with colon (:) and space.

If you do something wrong, the response from server will usually shortly indicate the type of error.

Presumably you'll need to write some bot program which will play instead of you, especially if the server requires that moves should be performed in limited amount of time (say, 10 seconds).


Example exchange

Suppose we are playing the game of tic-tac-toe. Then interaction between you and server may look like this:

You get the token from site and send it to server:

token: abcdefghijklmnopqrstuvwx

Server answers with initial position and its first move (in the center, with coordinates 1,1):

                                            move: 1 1
                                            pos: --- -X- ---

You send your move:

token: abcdefghijklmnopqrstuvwx
move: 2 2

and server updates the position and sends you its next move:

                                            move: 2 0
                                            pos: --X -X- --O

Your next move is to prevent lose in the corner:

token: abcdefghijklmnopqrstuvwx
move: 0 2

And the next response of the server is:

                                            move: 1 0
                                            pos: -XX -X- O-O

You now can complete a row of naughts:

token: abcdefghijklmnopqrstuvwx
move: 1 2

And server congratulates you:

                                            pos: -XX -X- OOO
                                            end: qfpaBLaH53m7jghi130xSi+V

You see, here is your victory token which you can submit at the site so that the problem is solved by you.


Ending

The word end always means the end of the game. You either get the victory token along with it, or it states that you lose the game. Usually you will see also some error explanation in separate line.

With certain errors you may get the error in response but without end. For example it happens if you send wrong token so the server could not identify you at all. In such cases you can resume the game after error.

If the game was ended you need to start another one. You however may use the same token if it had not expired yet.

Tokens expire in about 1 hour, so that if you get the token from the site yesterday, you probably will not be able to use it for playing and you need to generate another one.

At the same time the victory token should be submitted within a hour after you have won the game.