6
有誰知道我可以如何將一個混雜字母數組匹配到一個單詞,例如,一些函數匹配 數組,例如[「a」,「c」,「a」 , 「E」, 「C」]; 給一個單詞「ace」,給我1或者如果不是-1像indexOf或者InArray,但是對於一個混亂的單詞。 我已經做了一個js小提琴的例子,它是有據可查的將混雜數組匹配到字符串的函數
只是一個說明,我會比較字母數組從30000到50000字的任何地方。
https://jsfiddle.net/AlexanderMitrakis/89dchpt8/1/
this.gameletters = []; //Array of Game letters.
//e.g. ["P", "E", "H", "E", "U", "I", "S", "Q", "N"];
this.possiblesolution = new String(); //highest solution within gameletters
//e.g. "QUEENSHIP" (related to above letters)
this.wordBank = new Array();
//array of arrays structure is formated around alphabet with an array for each character:
/*
a: Array(7295)
b:Array(7271)
c:Array(11381)
d:Array(7216)
...
y:Array(607)
z:Array(623)
*/
你在哪裏存儲單詞的詞典嗎? – karthick
我將它存儲爲一個多維數組,因爲this.wordBank它存儲在wordBank中,按字母順序排序,然後在每個字符數組中按字母順序排列該字母中的所有單詞this.wordBank [character] [characterword] – AlexMika