0

Possible Duplicate:
How to find list of possible words from a letter matrix [Boggle Solver]

i am making a puzzle solver. So far i am doing all permutations of the word, but there are a lot! for a 12-letter word there are 479001600 perms... The game is a 16 letter puzzle (4x4)

 [A][B][C][D]
 [E][F][G][H]
 [I][J][K][L]
 [M][N][X][O]

A word can be made only with the letters that are around the selected letter. What i mean is that for example i cannot select the word AIM because I is not around A... But i can create the word "AFI". You select A then F(is diag. of A) and then I

My code for permutes is

  function permute( $tmp, $word, $level )
  {
      if ( strlen( $word ) > 2)
      {
          $this->display( $word );
          //return ;
      } 

      for ( $i = 0 ; $i < $this->original_word_length ; $i++ )
      {
          if ( $this->bOne_bond == true and $this->bonds[$level] != -1 and $i != $this->bonds[$level] and $level < $this->max_bonds ) continue ;

              if ( strcmp( $tmp{$i}, "N" ) == 0 )
              {
                  $word_tmp = $word ;
                  $word_tmp .= $this->original_word{$i};

                  $flags_tmp = $tmp ;
                  $flags_tmp{$i} = "Y";

                  $this->permute( $flags_tmp, $word_tmp, $level+1 );
              }
      } 
  }

How can i make my calculations based on neighboring letters?

EDIT: the solution is here. Thanks

Community
  • 1
  • 1
Nicos
  • 303
  • 2
  • 19
  • 1
    are you looking to implement something like http://www.scramblewithfriends-cheat.com/ ? – Andreas Wong May 09 '12 at 08:52
  • exactly! but its for a greek game called "ΛΕΞΕΙS" on iPad :) – Nicos May 09 '12 at 08:53
  • question regarding the rules, can you select the same letter twice, thrice, .... in successive ? like `AFFI` or `AFFFI` or repeating letters like `AFAFA` ? I would suggesting representing your data in a 2 dimensional array, hope that helps the adjacency problem – ianace May 09 '12 at 09:01
  • 1
    Tip: remove the question or answer it yourself and accept your own answer. – keyser May 09 '12 at 09:37

0 Answers0