Challenge
Make the shortest program to determine if the figures in the input will fit into the space in the input.
Requirements
The input will be in the format of this example: Input:
+----+ -- +--+
| +----+ | |
| | +--+
| |
+---------+
Output:
+----+
|+--++----+
|| |-- |
|+--+ |
+---------+
First, starting in the upper left corner, is the space that the program will try to fit the figures into. Then there is a space. Then there is a figure, in this case two dashes. Then there is a space, then a second figure. The output is the figures fitted inside of the space.
Rules about figures and input:
- The upper left corner of a shape will always be on the first row.
- After a figure, there is one space, as shown in the example.
- There is no limit on the size of the figures.
- The first figure will always be the space that the program will determine if the figures fit into.
- There is no limit on the number of figures, but there will only be one space to fit them into.
- All figures will be made of
|
and-
for the sides and+
for the corners. These are the only characters used besides spaces and newlines. - Figures cannot be rotated.
- Borders cannot overlap.
- You may fit one figure inside of another.
- The figures do not have to be closed.
- The space will always be closed.
- The space does not have to be completely filled.
- You may not split up shapes.
Rules about output:
- If the figures fit into the space, the program should output the figures inside of the space, as shown above. It does not matter how they are arranged, as long as no borders overlap, all figures are correct, and no shapes are split up.
- If the figures do not fit, output "no".
Examples
Input:
+--+ |
+--+
Output:
no
Input:
+---+ -+
| | |
| |
+---+
Output:
+---+
|-+ |
| | |
+---+
This is also valid:
+---+
| -+|
| ||
+---+
Input:
+----------+ +-----+ -+
| | | | |
| | | |
| | +-----+
| |
+----------+
Output:
+----------+
|+-----+ |
||-+ | |
|| | | |
|+-----+ |
+----------+
This is a code golf, so the shortest answer wins.
--
are misplaced in one of the first two images [Requirements]. \$\endgroup\$