title: My Boggle program won't find all the valid words - Java
body: <p>So I am working on a Boggle program in java and I am having trouble getting it to find every possible word. </p>
  
  <p>It finds almost all of them but for the life of me I cannot figure out why it won't get them all.</p>
  
  <pre><code>private void findWords( TreeSet&lt;String&gt; foundWords, String word, Tile t ){
      int i=t.getRow();
      int j=t.getCol();
  
      //Make sure the tile isn't visited
      if(visited[i][j]) return;
  
      //Set the current tile to visited
      visited[i][j]=true;
  
      //Decide what the current word is
      if(t.getLetter().equalsIgnoreCase("q")) word=word+"qu";
      else word=word+t.getLetter();
  
      //If the string is a word
      if(Boggle.dictionary.search(word)==1){
          //If the word length is greater than or equal to the prefix length
          if(word.length()&gt;=Dictionary.prefixLength){
              //If the word has not already been found
              if(!foundWords.contains(word)){
                  //Add the word to the found list
                  foundWords.add(word);   
              }
          }
      }
  
      //Recurse through all neighbor tiles
      for(int curRow=0; curRow&lt;=nRows; curRow++){
          for(int curCol=0; curCol&lt;=nCols; curCol++){
              //Make sure it is not out of bounds
              if((i+curRow&lt;nRows)&amp;&amp;(j+curCol&lt;nCols)){
                  findWords(foundWords, word, board[i + curRow][j + curCol]); 
                  findWords(foundWords, word, board[i - curRow][j - curCol]); 
  
                  findWords(foundWords, word, board[i + curRow][curCol]); 
                  findWords(foundWords, word, board[i - curRow][curCol]); 
  
                  findWords(foundWords, word, board[curRow][j + curCol]); 
                  findWords(foundWords, word, board[curRow][j - curCol]); 
  
                  findWords(foundWords, word, board[i + curRow][j - curCol]);
                  findWords(foundWords, word, board[i - curRow][j + curCol]);
              }
          }
      }
  
      //Reset the tile to be not visited
      visited[i][j] = false;
  }
  </code></pre>
  
  <p>This is the method in question; it recursively finds words on the Boggle board. </p>
  
  <p>Anyone have any ideas why it only finds about 75% of the words?</p>
  
  <p>I can attach more code if need be.</p>