Hi, all. I try to write a game "Pipes". It will be a console game. I have got two questions.

First question: The program must check - Is this placing of pipes possible on the field ? i.e. Will a player be able to collect pipes? How to do this checking?

Second question: Checking of pipes on a connectedness. How to check do pipes befit to each other, or not ?

Description of game:
On the screen is presented the playing field, on which are located the angular elements of kind: ┌, └, ┘ , ┐, –, |,+, and others. Task of player - for the minimum number of rotations of these elements to make a single line from them.
Example of game: http://home.earthlin...rn/pipegame.htm.
P.S. Sorry for my bad English. Hoping you understand me.