Have a look at this ascii art diagram of various boxes:
+--------------------------------------------------------------+
| |
| +-------------------------------+ +-------+ |
| | | | | |
| | | | | |
| | +----------------+ | | | |
| | | | | +-------+ |
| | | | | |
| | | | | +-------+ |
| | +----------------+ | | | |
| | | | | |
| | | | | |
| +-------------------------------+ +-------+ |
| |
+--------------------------------------------------------------+
Each box is formed with pipe characters for the vertical parts (|
), dashes for the horizontal parts (-
), and pluses for the corners (+
).
The diagram also shows boxes inside other boxes. We'll call the number of boxes that a box is contained within that box's layer. Here's the diagram again with the layer of each box annotated:
+--------------------------------------------------------------+
| |
| +-------------------------------+ +-------+ |
| | | | | |
| | | | 1 | |
| | +----------------+ | | | |
| | | | | 0 +-------+ |
| | | 2 | 1 | |
| | | | | +-------+ |
| | +----------------+ | | | |
| | | | 1 | |
| | | | | |
| +-------------------------------+ +-------+ |
| |
+--------------------------------------------------------------+
Your program will take in a box diagram similiar to the one at the top as input. As output, your program should output the box diagram with:
- The box on layer 0 should be filled with the character
#
(NB: There will only ever be one box on layer 0); - Boxes on layer 1 should be filled with the character
=
; - Boxes on layer 2 should be filled with the character
-
; - Boxes on layer 3 should be filled with the character
.
; - Boxes on layer 4 and above should not be filled.
Here is what the output of the example input should look like:
+--------------------------------------------------------------+
|##############################################################|
|###+-------------------------------+##########+-------+#######|
|###|===============================|##########|=======|#######|
|###|===============================|##########|=======|#######|
|###|=====+----------------+========|##########|=======|#######|
|###|=====|----------------|========|##########+-------+#######|
|###|=====|----------------|========|##########################|
|###|=====|----------------|========|##########+-------+#######|
|###|=====+----------------+========|##########|=======|#######|
|###|===============================|##########|=======|#######|
|###|===============================|##########|=======|#######|
|###+-------------------------------+##########+-------+#######|
|##############################################################|
+--------------------------------------------------------------+
Here is another input and output showing layers 3, 4, and 5. Note the horizontal lines at the top that are very close together. In these cases there is not enough space to fill any characters there.
+-----------------------------------------------------------------------+
| +--------------------------------------------------------------+ |
| | +-----------------------------------------------------+ | |
| | | +-----------------------------------------+ | | |
| | | | +---------------------------+ | | | |
| | | | | +-------------+ | | | | |
| | | | | | | | | | | |
| | | | | +-------------+ | | | | |
| | | | +---------------------------+ | | | |
| | | | | | | |
| | | +-----------------------------------------+ | | |
| | | | | |
| | | | | |
| | +-----------------------------------------------------+ | |
| | | |
| +--------------------------------------------------------------+ |
| |
| |
| |
+-----------------------------------------------------------------------+
The output:
+-----------------------------------------------------------------------+
|#####+--------------------------------------------------------------+##|
|#####|======+-----------------------------------------------------+=|##|
|#####|======|---------+-----------------------------------------+-|=|##|
|#####|======|---------|...........+---------------------------+.|-|=|##|
|#####|======|---------|...........| +-------------+ |.|-|=|##|
|#####|======|---------|...........| | | |.|-|=|##|
|#####|======|---------|...........| +-------------+ |.|-|=|##|
|#####|======|---------|...........+---------------------------+.|-|=|##|
|#####|======|---------|.........................................|-|=|##|
|#####|======|---------+-----------------------------------------+-|=|##|
|#####|======|-----------------------------------------------------|=|##|
|#####|======|-----------------------------------------------------|=|##|
|#####|======+-----------------------------------------------------+=|##|
|#####|==============================================================|##|
|#####+--------------------------------------------------------------+##|
|#######################################################################|
|#######################################################################|
|#######################################################################|
+-----------------------------------------------------------------------+
Another input, this time with the vertical lines close together as well:
+-------------+
|+-----------+|
|| ||
|| ||
|| ||
|+-----------+|
+-------------+
The output:
+-------------+
|+-----------+|
||===========||
||===========||
||===========||
|+-----------+|
+-------------+
Additional Notes
- There can be whitespace around the outermost box.
- Boxes cannot have an internal width or height of 0 (so they'll always be some space inside them)
- Boxes on the same layer can touch each other.