可能重复:
How to find list of possible words from a letter matrix [Boggle Solver]
我正在制作拼图解算器。到目前为止,我正在做这个词的所有排列,但有很多! 12个字母的单词有479001600个烫发... 游戏是16个字母拼图(4x4)
[A][B][C][D]
[E][F][G][H]
[I][J][K][L]
[M][N][X][O]
只能使用所选字母周围的字母来创建单词。我的意思是,例如我不能选择AIM这个词,因为我不在A ... 但我可以创建“AFI”这个词。你选择A然后F(是A的诊断)然后我
我的permutes代码是
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 );
}
}
}
如何根据相邻字母进行计算?
编辑: 解决方案是here。感谢