CODE WARS ]I[ PROGRAMMING COMPETITION
Four Word Cross Word
Problem 14 Division I 17 Points
Problem Statement
Crossword puzzles and word search puzzles have been a popular pastime for many people throughout the years. Write a program that can arrange four words in a rectangular crossword pattern.
Program Input
The input file PROG14.IN will contain four words, each on a separate line. For example:
economics
speech
chemistry
communications
Program Output
The program should write a rectangular crossword to the output file PROG14.OUT. Each word must be connected to two other words in such a way as to form a rectangular region as shown in the example below. All words must read either top to bottom or left to right. They may be arranged and connected in any order, as long as the output forms a rectangle in the center. Diagonal words are not permitted.
     If the program is unable to find a solution to the input, it should write the message NO SOLUTION FOUND.

  e
  chemistry
  o    p
  n    e
  o    e
communications
  i    h
  c
  s