title: using recursion and a 2D array to make words intersect at similar letters
body: <p>My class recently was assigned a program in which we need to create a crossword puzzle, using a 2D array, as well as recursion. The instructions are as follows:</p>
  
  <p>***Write a program that reads words from an input file called words.txt, creating a crossword display maximizing the overlapping letters between words.  Assume the board has 15 rows and 15 columns.</p>
  
  <p>The first line of the input file is ``a number representing how many words are present.  The words are then provided, one per line.  As your program runs it should display the solutions it finds, along with the count of number of overlaps for each one.  At the end it should display the solution with the maximum number of overlaps found, or a message if no crossword puzzle is possible.<em>*</em></p>
  
  <p>I am having a ton of trouble wrapping my mind around this concept. I understand the need for embedded 'for' loops to cycle the recursion, but I am not sure where to go from there.
  Some sample code to get us started is as entails:</p>
  
  <pre><code>/* Dictionary.java
  *    Read in words from a file.  The first line in the file should
  *    be the number of words.  Subsequent lines have the words 
  *    themselves, one per line.  For instance, a sample file 
  *    could contain:
  *       5
  *           Java
  *       Programming
  *       Euphoria
  *       Consternation
  *  Education
  *    
  *    This sample code is not meant to be stand-alone, but rather
  *    is meant for you to copy and paste into some other class.
  */
  
  //the following are needed to implement reading from the file
  import java.io.*;               // Used for IOException, File
  import java.util.Scanner;       // Used for File input
  
  
  public class ReadWords 
  {
  // Declare an array of strings to hold the words
  String[] wordsArray;
  
  
  // chain off to another method to avoid static errors
  public static void main( String[] args) 
  {
  ReadWords theInstance = new ReadWords();
  theInstance.doIt();
  }
  
  
  // ------------------------------------------------------------------------
  // Read in the words 
  void doIt()
  {    // Use a try-catch block for exception handling. What this does is
  // provide a place in your program to handle potential file read errors
  try {
  // Define a Scanner to read from an input file.  Note that the name of
  // the file given in the code below MUST match the actual filename of
  // the words file.  This file should be in the same directory
  // as the source code for this project
  File wordsFile = new File("words.txt");    // declare the file
  
  // Ensure file exists and is in the correct directory
  if( ! wordsFile.exists()) {
  System.out.println("*** Error *** \n" +
  "Your words file has the wrong name or is " +
  "in the wrong directory.  \n" +
  "It should be in " + System.getProperty("user.dir") + "\n" +
  "\n" +
  "Aborting program...\n\n");
  System.exit( -1);    // Terminate the program
  }
  Scanner inputFile = new Scanner( wordsFile);
  
  // while there are words in the input file, add them to the dictionary
  int numberOfWords = inputFile.nextInt();
  
  // use this value to allocate memory for the words array
  wordsArray = new String[ numberOfWords];
  
  // Now read this many words
  for( int i=0; i&lt; wordsArray.length; i++) {
  // read next word and store into array
  wordsArray[ i] = inputFile.next().toUpperCase();    
  }
  
  }
  catch (IOException e)
  {
  System.out.println("Error in words file read");
  System.exit( -1);
  }
  
  // echo the words found
  System.out.println("The words read are: ");
  for( int i=0; i&lt; wordsArray.length; i++) {
  System.out.println( wordsArray[ i]);
  }
  }//end doIt()
  
  }//end class
  </code></pre>
  
  <p>If anyone has any suggestions or recommendations on where this should go, it would be most helpful.</p>