Humpty Dumpty
Humpty Dumpty rode on a board.
Humpty Dumpty fell and was floored.
Broke into pieces, splattered and bruised,
Humpty's poor face may never be fused.
Humpty Dumpty is a rather reckless skateboarder who has just taken a fall, and broken into a few pieces. Previously his face was represented by a square, but this square has broken into 9 square shaped pieces with some jigsaw-like appendages.
Assuming you can rotate, but not flip the face pieces, can you put Humpty Dumpty together again?
Input
Input will contain 9 lines, each containing 4 characters. Each line represents a singular square piece of Humpty's face, and each character represents a side of of the square piece, read in clockwise order:
- A
-
character represents a side which must face the edge of Humpty's face - A lowercase character from
a-z
must be directly next to the corresponding uppercase characterA-Z
in the completed face of Humpty
Output
Output should consist of 7 lines, each containing 7 characters, representing a fixed version of Humpty's face. See the Example section for the structure of this output. If there are multiple possible solutions, then print the lexicographically smallest one. For two letter pieces joining together, use the lowercase character to represent their join:
Example
For puzzle pieces
- - a C
B d A -
b - - e
H - c F
f D G i
g E - j
K - - h
k I L -
- l J -
The lexicographically smallest solution places a
at the first possible connection, leading to the solution:
+-+-+-+
| a b |
+c+d+e+
| f g |
+h+i+j+
| k l |
+-+-+-+
Comments