Problem J
Connect the Dots
Write a program to read in a visual description of a connect-the-dots puzzle, then connect the dots and print the result.
Input
Input contains up to
Output
For each image, print out the dots-connected image, as illustrated in the sample output. Connected dots will always be vertically or horizontally related; there are no diagonal lines. The lines should not obscure any dots, and if two lines cross, then indicate that as shown with a plus (+). Do not connect the last dot with the first dot. Produce a blank line between each pair of images.
Sample Input 1 | Sample Output 1 |
---|---|
.....0.......1 .............. .............. .....3.......2 ..0.....4...... ............... ............... ............... ..2.....3.....7 ............... ............... ............... ..1.....5.....6 ..0...............7...........8....d ......4................3............ .................................... .................................... ...........a..................9..... .................................... ..1....................2............ .................................... ......5...........6................. .................................... ...........b.......................c |
.....0-------1 .............| .............| .....3-------2 ..0.....4...... ..|.....|...... ..|.....|...... ..|.....|...... ..2-----3.....7 ..|.....|.....| ..|.....|.....| ..|.....|.....| ..1.....5-----6 ..0...............7-----------8....d ..|...4-----------+----3......|....| ..|...|...........|....|......|....| ..|...|...........|....|......|....| ..|...|....a------+----+------9....| ..|...|....|......|....|...........| ..1---+----+------+----2...........| ......|....|......|................| ......5----+------6................| ...........|.......................| ...........b-----------------------c |