Quote:
Originally Posted by Kristi
yes but you also have to find which arrangements are actually words in the dictionary.... fun fun fun
|
Are we given said dictionary?
edit:
NPC Code:
function arrange(letters,first) {
temp.len = letters.length();
if (first == 0) first = "";
if (temp.len > 1) {
temp.returns.clear();
temp.htable = {0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,1};
for (temp.i=0; temp.i<temp.len; temp.i++) {
temp.letter = letters.charat(temp.i).tolower();
temp.hindex = (max(96,min(123,getascii(temp.letter)))-97)%27; // maps characters outside of a-z to htable[26]
if (temp.htable[temp.hindex] == 0) {
temp.htable[temp.hindex] = 1;
temp.pref= first @ temp.letter;
temp.endings = arrange(letters.substring(0,temp.i) @ letters.substring(temp.i+1),temp.pref);
temp.returns.addarray(temp.endings);
}
}
return temp.returns;
}
else {
temp.word = first @ letters.tolower();
if (inDictionary(temp.word))
return {temp.word};
else return char(0);
}
}
Now I just need some
inDictionary(word).