Bien... este problema lo he sacado de un concurso de programacion, y la verdad es que me costo un poco resolverlo (bien por que mi forma no era la mejor o bien por que soy un torpe
)
El enunciado esta en ingles, aunque la verdad es que tampoco es muy dificil de entender:
A braid is made of one or more loops interlaced in fanciful forms. Surprisingly, every braid can be represented graphically using just four characters: blanks, dashes, bars and the plus sign.
The goal of this simple programming exercise is to find the number of loops thet integrate a given braid.
INPUT DESCRIPTION
Several braid descriptions, separated by empty lines. Each braid is given using the four characters as explained above, is well formed and is representated unambiguosly. The input is finished by the end of file.
OUTPUT DESCRIPTION
For each braid, a line with the numbre of loops contained in it.
SAMPLE IMPUT
+----+
| |
+----+ |
| | | |
+--|----+
| |
+-+
+--+ +--+ +--+
| | | | | |
+-----|--|-----+
| | | |
+--+ +--+
+--------+
| |
+--------+ |
| | | |
| +--------+
| |
+--------+ |
| | | |
+--|-----+ |
+--------+
SAMPLE OUTPUT