/*******************************************************
 * WORD FILTER                                         *
 * (JavaScript program logic)                          *
 *                                                     *
 * Copyright (C) 2011, Scott Pakin, scott+wf@pakin.org *
 *                                                     *
 *******************************************************/

var _sp0=15;var _sp1=1;var _sp2;var _sp3;var _sp4;var _sp5=[];var _sp6;var _sp7;var _sp8={};var _sp9={};var _sp10=[];var wordListChanged=true;var _sp11=5000;var _sp12=0.1;var alphabet="abcdefghijklmnopqrstuvwxyz";function _sp13(_1){return document.getElementById(_1);};function toggleDisplay(_2){var _3=_sp13(_2);_3.style.display=(_3.style.display=="block")?"none":"block";};function toggleInstructions(_4){var _5=document.getElementsByTagName("p");for(var p=0;p<_5.length;p++){var _6=_5[p];if(_6.className=="new-step"||_6.className=="same-step"){_6.style.display=(_6.style.display=="none")?"block":"none";}
}
for(var i=1;i<=2;i++){var _7=_sp13("toggle-instructions-"+i);if(_7.textContent.search(/Hide/)==-1){_7.textContent="Hide instructions";}else{_7.textContent="Show instructions";}
}
};function _sp16(_8){if(_8){_sp13("word-list").setAttribute("readonly","readonly");}else{_sp13("word-list").removeAttribute("readonly");}
_sp13("reset-list").disabled=_8;_sp13("toggle-list").disabled=_8;_sp13("set-list").disabled=_8;_sp13("process-word-length").disabled=_8;_sp13("process-must-contain").disabled=_8;_sp13("process-num-occurrences").disabled=_8;_sp13("process-subset").disabled=_8;_sp13("process-letter-set").disabled=_8;_sp13("process-letter-pattern").disabled=_8;_sp13("process-regular-expression").disabled=_8;_sp13("process-guess-word").disabled=_8;_sp13("process-undo").disabled=_sp10.length==0?true:_8;_sp13("current-guess-text").style.display="none";if(!_8){checkInteger(_sp13("word-length-val"),"process-word-length");checkInteger(_sp13("num-occurrences-val"),"process-num-occurrences");checkMustContain();checkLetters(_sp13("letter-set-letters"),"process-letter-set");checkLetterPattern();checkRegexp();}
};function checkInteger(_9,_a){var _b=_sp13(_a);_9.value=_9.value.replace(/\D+/g,"");_b.disabled=_9.value=="";};function checkLetters(_c,_d){var _e=_sp13(_d);_c.value=_c.value.toUpperCase().replace(/[^A-Z]+/g,"");_e.disabled=_c.value=="";};function checkMustContain(){var _f=_sp13("must-contain");var _10=_f.value.toUpperCase().replace(/[^A-Z]+/g,"");_f.value=_10;_sp13("process-must-contain").disabled=_10=="";var _11=_sp13("must-contain-pos");if(_10.length>1){_11.selectedIndex=0;_11.disabled=true;}else{_11.disabled=false;}
};function checkLetterPattern(){var _12=_sp13("letter-pattern");var _13=_12.value.replace(/[^-A-Za-z]+/g,"");_12.value=_13;_sp13("process-letter-pattern").disabled=_13=="";};function checkRegexp(){try{var _14=_sp13("regular-expression").value;var _15=new RegExp(_14);_sp13("process-regular-expression").disabled=_14=="";}
catch(ex){_sp13("process-regular-expression").disabled=true;}
};function _sp20(){if(_sp2.length<2){return 0;}
if(_sp5.length<2){return Math.ceil(Math.log(_sp2.length)/Math.log(3))+1;}
var _16=_sp2[0].split("").sort().join("");var _17=true;for(var i=0;i<_sp2.length;i++){var _18=_sp2[i].split("").sort().join("");if(_18!=_16){_17=false;break;}
}
if(_17){var _19=_sp2.length;for(var i=0;i<_sp2.length;i++){if(_sp8[_sp2[i]]==1){_19--;}
}
return Math.max(_19-1,0);}
var _1a=1;for(var i=1;i<_sp5.length;i++){_1a*=_sp5[i-1]/_sp5[i];}
_1a=Math.pow(_1a,1/(_sp5.length-1));var _1b;if(_1a>1){_1b=Math.ceil(Math.log(_sp2.length)/Math.log(_1a));}else{_1b=Math.ceil(Math.log(_sp2.length)/Math.log(3))+1;}
if(_sp2.length<10000){var _1c={};for(var i=0;i<_sp2.length;i++){var _18="!"+_sp2[i].split("").sort().join("");if(_1c[_18]==undefined){_1c[_18]=1;}else{_1c[_18]++;}
if(_1c[_18]-1>_1b){_1b=_1c[_18]-1;}
}
}
return _1b;};function _sp27(_1d){var _1e=_sp2.length;if(_1e==1&&_sp2[0]==""){_1e=0;}
_sp13("word-count").innerHTML=_1e.toString()+" "+(_1e==1?"word remains.":"words remain.");var _1f="";switch(_1e){case 0:
_1f="(Either the mystery word was not in the original word list or incorrect information was provided to the program.)";break;case 1:
_1f="(The mystery word has been identified.)";break;default:
var _20=_sp20();if(_20>=0){_20=Math.max(_20,1);_1f="(The mystery word will be identified after approximately "+_20+(_sp5.length>0?" more ":" ")+(_20==1?"guess":"guesses")+".)";}
break;}
_sp13("guesses-remaining").innerHTML=_1f;setTimeout(function(){_1d(_1e);},_sp12);};function _sp31(_21){var _22=_sp13(_21);var _23;for(var i=0;i<_22.childNodes.length;i++){_23=_22.childNodes[i];if(_23 instanceof HTMLOptionElement){break;}
}
var _24=alphabet.toUpperCase().slice(1);_24=_24.split("");for(var i=1;i<arguments.length;i++){_24.push(arguments[i]);}
for(var pos=0;pos<_24.length;pos++){var _25=_23.cloneNode(true);_25.text=_24[pos];_22.appendChild(_25);}
_22.selectedIndex=0;};function _sp36(_26){var _27=_sp13(_26);var _28=_27.firstChild;for(var i=0;i<_27.childNodes.length;i++){_28=_27.childNodes[i];if(_28 instanceof HTMLOptionElement){break;}
}
for(var len=_sp1;len<=_sp0+1;len++){var _29=_28.cloneNode(true);_29.text="at position "+len.toString();_27.appendChild(_29);}
_27.lastChild.text="as the last letter of the word";_27.selectedIndex=0;};var _sp37=new Array({_sp43:0,_sp44:100});var _sp38=0;var _sp39=0;function _sp40(_2a){_sp38=pageXOffset;_sp39=pageYOffset;_sp37=new Array({_sp43:0,_sp44:100});_sp49(0);_sp13("progress-box-title").innerHTML=_2a;_sp13("command-list").style.display="none";_sp13("progress-box").style.display="block";};function _sp41(_2b,_2c){var _2d=_sp37[_sp37.length-1];var _2e=_2d._sp43;var _2f=_2d._sp44;var _30=_2e+(_2f-_2e)*_2b/100;var _31=_2e+(_2f-_2e)*_2c/100;_sp37.push({_sp43:_30,_sp44:_31});};function _sp47(){_sp37.pop();};function _sp48(_32,_33){_sp47();_sp41(_32,_33);};function _sp49(_34){if(_34>100){_34=100;}
var _35=_sp37[_sp37.length-1];var _36=_35._sp43;var _37=_35._sp44;_34=_36+_34*(_37-_36)/100;_sp13("progress-bar-text").innerHTML=Math.floor(_34).toString()+"%";_sp13("progress-bar-bar").style.width=_34.toString()+"%";};function _sp50(){_sp13("progress-box").style.display="none";_sp13("command-list").style.display="block";scrollTo(_sp38,_sp39);};function _sp51(_38){var _39=_38.slice();if(_39.length<2){return _39;}
if(arguments.length>1){_39.sort(arguments[1]);}else{_39.sort();}
if(_39[_39.length-1]==undefined){var _3a="JavaScript's Array.sort() method lost data.  Program is unable to run correctly.";alert(_3a);_sp13("progress-box").style.display="none";throw _3a;}
return _39;};function _sp54(_3b){var _3c={};for(var i=_3b.length-1;i>=0;i--){_3c[_3b[i]]=1;}
var _3d=[];for(var elt in _3c){_3d.push(elt);}
return _sp51(_3d);};function _sp56(_3e){_sp2=_sp13("word-list").value.toLowerCase().replace(/\s+/gm,"\n").split("\n");var _3f={};var _40=[];var _41=function(i,_42){for(;i<_sp2.length;i++){var _43=_sp2[i];if(_43.length>=_sp1&&_43.length<=_sp0){_3f[_43]=1;}
if(i%_sp11==0){if(_sp2.length>1){_sp49(i*50/(_sp2.length-1));}
setTimeout(function(){_41(i+1,_42);},_sp12);return;}
}
_sp49(50);setTimeout(_42,_sp12);};_sp3=_sp0+1;_sp4=_sp1-1;var _44=function(i,_45){var _46=i;for(var _47 in _3f){_40[i++]=_47;var _48=_47.length;if(_sp3>_48){_sp3=_48;}
if(_sp4<_48){_sp4=_48;}
if(i%_sp11==0){if(_sp2.length>1){_sp49(50+i*50/(_sp2.length-1));}
for(var j=_46;j<_40.length;j++){delete _3f[_40[j]];}
setTimeout(function(){_44(i,_45);},_sp12);return;}
}
_sp49(100);setTimeout(_45,_sp12);};var _49=function(_4a){_sp2=_sp51(_40);_sp13("word-list").value=_sp2.join("\n");wordListChanged=false;setTimeout(_4a,_sp12);};_41(0,function(){_44(0,function(){_49(function(){setTimeout(_3e,_sp12);});});});};function _sp63(_4b,_4c,_4d){_sp3=_4b;_sp4=_4c;_sp41(0,100);var _4e=0;var _4f=function(_50){if(wordListChanged){_sp48(0,50);_4e=50;_sp56(_50);}else{setTimeout(_50,_sp12);}
};var _51=[];var _52=function(i,_53){if(i==0){_sp48(_4e,100);}
for(;i<_sp2.length;i++){var _54=_sp2[i];if(_54.length>=_4b&&_54.length<=_4c){_51.push(_54);}else{wordListChanged=true;}
if(i%_sp11==0){if(_sp2.length>1){_sp49(i*100/(_sp2.length-1));}
setTimeout(function(){_52(i+1,_53);},_sp12);return;}
}
_sp49(100);setTimeout(_53,_sp12);};_4f(function(){_52(0,function(){_sp2=_51;_sp13("word-list").value=_sp2.join("\n");_sp47();setTimeout(_4d,_sp12);});});};function _sp67(_55,_56,_57,_58,_59){_sp41(0,100);var _5a=0;var _5b=function(_5c){if(wordListChanged){_sp48(0,50);_5a=50;_sp56(_5c);}else{setTimeout(_5c,_sp12);}
};var _5d=[];var _5e;switch(_55){case 0:
_5e=function(a){return (a==_56);};break;case 1:
_5e=function(a){return (a>=_56);};break;case 2:
_5e=function(a){return (a<=_56);};break;}
var _5f={};for(var c=_57.length-1;c>=0;c--){var _60=_57[c];if(_5f[_60]==undefined){_5f[_60]=1;}else{_5f[_60]++;}
}
var _61=function(i,_62){for(;i<_sp2.length;i++){var _63=_sp2[i];var _64=0;for(var c=_63.length-1;c>=0;c--){if(_63[c]==_57[c]){_64++;}
}
var _65=0;var _66={};for(var key in _5f){_66[key]=_5f[key];}
for(var c=_63.length-1;c>=0;c--){var _67=_63[c];if(_66[_67]!=undefined&&_66[_67]>0){_65++;_66[_67]--;}
}
switch(_58){case 0:
if(_5e(_65)){_5d.push(_63);}else{wordListChanged=true;}
break;case 1:
if(_5e(_64)){_5d.push(_63);}else{wordListChanged=true;}
break;case 2:
if(_5e(_65-_64)){_5d.push(_63);}else{wordListChanged=true;}
break;}
if(i%_sp11==0){if(_sp2.length>1){_sp49(i*100/(_sp2.length-1));}
setTimeout(function(){_61(i+1,_62);},_sp12);return;}
}
_sp49(100);setTimeout(_62,_sp12);};_5b(function(){_sp48(_5a,100);_61(0,function(){_sp2=_5d;_sp13("word-list").value=_sp2.join("\n");_sp47();setTimeout(_59,_sp12);});});};function _sp75(_68,_69,_6a){var _6b=0;_sp41(0,100);var _6c=function(_6d){if(wordListChanged){_sp48(0,50);_6b=50;_sp56(_6d);}else{setTimeout(_6d,_sp12);}
};var _6e=[];var _6f=function(i,_70){for(;i<_sp2.length;i++){var _71=_sp2[i];for(var r=0;r<_68.length;r++){if((_71.search(_68[r])==-1)==_69){break;}
}
if(r==_68.length){_6e.push(_71);}else{wordListChanged=true;}
if(i%_sp11==0){if(_sp2.length>1){_sp49(i*100/(_sp2.length-1));}
setTimeout(function(){_6f(i+1,_70);},_sp12);return;}
}
_sp49(100);setTimeout(_70,_sp12);};_6c(function(){_sp48(_6b,100);_6f(0,function(){_sp2=_6e;_sp13("word-list").value=_sp2.join("\n");_sp47();setTimeout(_6a,_sp12);});});};function processWordLength(){_sp16(true);_sp166();var _72=(_sp13("uniqueness").selectedIndex==1);var _73=_sp13("word-length-val");var _74=Number(_73.value);var _75=_sp13("word-length");var _76=function(_77){var _78=_72?"letters or that contain duplicate letters":"letters";switch(_75.selectedIndex){case 0:
_sp40("Discarding words that do not contain exactly "+_74.toString()+" "+_78+"&hellip;");if(_72){_sp41(0,50);}
_sp63(_74,_74,_77);break;case 1:
_sp40("Discarding words shorter than "+_74.toString()+" "+_78+"&hellip;");if(_72){_sp41(0,50);}
_sp63(_74,_sp0,_77);break;case 2:
_sp40("Discarding words longer than "+_74.toString()+" "+_78+"&hellip;");if(_72){_sp41(0,50);}
_sp63(_sp1,_74,_77);break;}
};var _79=function(_7a){if(_72){_sp48(50,100);_sp75(new Array("(.).*\\1"),false,_7a);}else{setTimeout(_7a,_sp12);}
};setTimeout(function(){_76(function(){_79(function(){_sp27(function(){_sp47();_sp50();_sp16(false);});});});},_sp12);};function processMustContain(){_sp16(true);_sp166();var _7b=_sp13("must-or-must-not-contain").selectedIndex==0;var _7c=_sp13("must-contain").value;var _7d=_sp13("must-contain-pos");var _7e=_7d.selectedIndex-1;var _7f;_7c=_sp51(_sp54(_7c.split(""))).join("");var _80="letter \""+_7c.toUpperCase()+"\"";_7c=_7c.toLowerCase();switch(_7e){case -1:
if(_7c.length==1){_7f=new Array(_7c);}else{_7f=_sp54(_7c);if(_7f.length>1){_80="letters {"+_7f.join(", ").toUpperCase()+"}";}
}
break;case _sp0:
_7f=new Array(_7c+"$");break;default:
_7f=new Array("^.{"+_7e.toString()+"}"+_7c);break;}
_sp40("Discarding words that "+(_7b?"do not ":"")+"contain the "+_80+" "+_7d.value+"&hellip;");setTimeout(function(){_sp75(_7f,_7b,function(){_sp27(function(){_sp50();_sp16(false);});});},_sp12);};function processNumOccurrences(){_sp16(true);_sp166();var _81=_sp13("num-occurrences-letter");var _82=_81[_81.selectedIndex].value.toLowerCase();var _83=_sp13("num-occurrences-val").value;var _84="^([^LETTER]*LETTER){COUNT}[^LETTER]*$";var _85=[];var _86;var _87;switch(_sp13("num-occurrences").selectedIndex){case 0:
_87="Discarding words that do not contain exactly";var _88=_84.replace(/COUNT/,_83);_85.push(_88.replace(/LETTER/g,_82));_86=true;break;case 1:
_87="Discarding words that contain fewer than";var _88=_84.replace(/COUNT/,_83+",");_85.push(_88.replace(/LETTER/g,_82));_86=true;break;case 2:
_87="Discarding words that contain more than";var _89=Number(_83)+1;var _88=_84.replace(/COUNT/,_89+",");_85.push(_88.replace(/LETTER/g,_82));_86=false;break;}
_sp40(_87+" "+_83+" "+(_83==1?"instance":"instances")+" of the letter \""+_82.toUpperCase()+"\"&hellip;");setTimeout(function(){_sp75(_85,_86,function(){_sp27(function(){_sp50();_sp16(false);});});},_sp12);};function processSubset(){_sp16(true);_sp166();var _8a=_sp13("subset-type");var _8b=parseInt(_sp13("subset-size").value,10);var _8c=_sp13("subset-letters").value;var _8d=_sp13("subset-match").selectedIndex;var _8e;switch(_8d){case 0:
_8e="at any position";break;case 1:
_8e="at the same position";break;case 2:
_8e="at a different position";break;}
_sp40("Discarding words that do not have "+_8a.value+" "+_8b+" of the letters in {"+_8c.split("").join(", ")+"} "+_8e+"&hellip;");_8c=_8c.toLowerCase().split("");_8a=_8a.selectedIndex;setTimeout(function(){_sp67(_8a,_8b,_8c,_8d,function(){_sp27(function(){_sp50();_sp16(false);});});},_sp12);};function processLetterSet(){_sp16(true);_sp166();var _8f=_sp13("letter-set-letters").value.toLowerCase();var _90=[];switch(_sp13("letter-set").selectedIndex){case 0:
_sp40("Discarding words that contain letters not in the set {"+_sp54(_8f.toUpperCase()).join(", ")+"}&hellip;");_90.push("^["+_sp54(_8f).join("")+"]+$");break;case 1:
_sp40("Discarding words that cannot be formed from {"+_8f.toUpperCase().split("").join(", ")+"}&hellip;");_90.push("^["+_sp54(_8f).join("")+"]+$");var _91={};for(var c=_8f.length-1;c>=0;c--){var _92=_8f[c];if(_91[_92]==undefined){_91[_92]=1;}else{_91[_92]++;}
}
var _93="^([^LETTER]*LETTER){0,COUNT}[^LETTER]*$";for(var _92 in _91){var _94=_93;_94=_94.replace(/LETTER/g,_92);_94=_94.replace(/COUNT/g,_91[_92]);_90.push(_94);}
break;case 2:
_sp40("Discarding words that are not anagrams of \""+_8f.toUpperCase()+"\"&hellip;");_90.push("^.{"+_8f.length+"}$");var _91={};for(var c=_8f.length-1;c>=0;c--){var _92=_8f[c];if(_91[_92]==undefined){_91[_92]=1;}else{_91[_92]++;}
}
var _93="^([^LETTER]*LETTER){COUNT}[^LETTER]*$";for(var _92 in _91){var _94=_93;_94=_94.replace(/LETTER/g,_92);_94=_94.replace(/COUNT/g,_91[_92]);_90.push(_94);}
break;}
setTimeout(function(){_sp75(_90,true,function(){_sp27(function(){_sp50();_sp16(false);});});},_sp12);};function processLetterPattern(){_sp16(true);_sp166();var _95=_sp13("letter-pattern").value;var _96=[];_sp40("Discarding words that do not match the pattern <tt>"+_95+"</tt>&hellip;");var _97="^"+_95.replace(/-/g,".")+"$";_97=_97.replace(/[a-z]/g,"[^$&]");_97=_97.toLowerCase();_96.push(_97);var _98=_sp54(_95.replace(/[^a-z]/g,""));for(var c=_98.length-1;c>=0;c--){_96.push(_98[c]);}
if(_sp13("more-occurrences").selectedIndex==1){_98=_sp54(_95.toLowerCase().replace(/[^a-z]/g,""));for(var c=_98.length-1;c>=0;c--){var _99=_98[c];var _9a=_95.match(new RegExp(_99,"gi")).length;var _97="^([^LETTER]*LETTER){COUNT}[^LETTER]*$";_97=_97.replace(/LETTER/g,_99);_97=_97.replace(/COUNT/g,_9a);_96.push(_97);}
}
setTimeout(function(){_sp75(_96,true,function(){_sp27(function(){_sp50();_sp16(false);});});},_sp12);};function processRegexp(){_sp16(true);_sp166();var _9b=_sp13("must-or-must-not-match").selectedIndex==0;var _9c=_sp13("regular-expression").value;_sp40("Discarding words that "+(_9b?"do not ":"")+"match the regular expression <tt>"+_9c+"</tt>&hellip;");var _9d=new Array(_9c);setTimeout(function(){_sp75(_9d,_9b,function(){_sp27(function(){_sp50();_sp16(false);});});},_sp12);};function _sp96(_9e,_9f){var _a0={};var _a1=_9e.replace(/\r/g,"").split("\n");var i=0;var _a2=function(i,_a3){if(i<alphabet.length){_sp49(i*100/(alphabet.length-1));var _a4=alphabet[i];var _a5=new RegExp("^.*"+_a4+".*$","gm");var _a6=_9e.match(_a5);if(_a6==null){_a0[_a4]=0;}else{_a0[_a4]=_a6.length;_a5=new RegExp(_a4,"g");var _a7=_9e.match(_a5).length;_a0[_a4]+=_a7/(10*_a1.length);}
setTimeout(function(){_a2(i+1,_a3);},_sp12);}else{setTimeout(_a3,_sp12);}
};setTimeout(function(){_a2(0,function(){_9f(_a0);},1);},_sp12);};function _sp103(_a8,_a9,_aa){var _ab=0;var _ac;_sp41(0,100);var _ad=function(_ae){if(wordListChanged){_ac=100/2;_sp48(_ab,_ab+_ac);_ab+=_ac;_sp56(function(){_a8=_sp2.join("\n");_sp27(_ae);});}else{_ac=100/1;setTimeout(_ae,_sp12);}
};var _af;var _b0=function(_b1){_sp118=_sp2.join("\n");_sp48(_ab,_ab+_ac);_ab+=_ac;_sp96(_sp118,function(lw){_af=lw;setTimeout(_b1,_sp12);});};var _b2=0;var _b3="?";var _b4=_sp2.length>1?_sp2.length:-1;var _b5=function(_b6){for(var _b7 in _af){if(_af[_b7]>_b2&&Math.floor(_af[_b7])!=_b4&&_sp9[_b7]==undefined){_b3=_b7;_b2=_af[_b7];}
}
if(_b3=="?"){for(var _b7 in _af){if(_af[_b7]>_b2){_b3=_b7;_b2=_af[_b7];}
}
}
_sp49(100);_sp47();setTimeout(function(){_b6(_b3,"");},_sp12);};setTimeout(function(){_ad(function(){_b0(function(){_b5(_aa);});});},_sp12);};function _sp110(_b8,_b9,_ba){var _bb=new Date().getTime();var _bc=0;var _bd=0;var _be=0;var _bf;_sp41(0,100);var _c0;var _c1=wordListChanged;var _c2=function(_c3){if(wordListChanged){_bf=100/20;_sp48(_be,_be+_bf);_be+=_bf;_sp56(function(){if(_b8==_sp6){_c0=_sp7;}else{_c0=_sp2;_b8=_sp2.join("\n");}
_sp48(_be,_be+_bf);_be+=_bf;_sp27(_c3);});}else{_c0=_b8.replace(/\r/g,"").split("\n");_bf=100/19;_sp48(_be,_be+_bf);_be+=_bf;setTimeout(_c3,_sp12);}
};var _c4="";var _c5=function(_c6){if(_sp2.length<3){_sp47();setTimeout(function(){_ba(_sp2[Math.floor(Math.random()*_sp2.length)],"");},_sp12);return;}
setTimeout(_c6,_sp12);};var _c7={};var _c8;var _c9=function(i,_ca){for(;i<_sp2.length;i++){_c7[_sp2[i]+"!"]=1;if(i%_sp11==0){_sp49(i*100/(_sp2.length-1));setTimeout(function(){_c9(i+1,_ca);},_sp12);return;}
}
_c8=_sp2.join("\n");_sp48(_be,_be+_bf);_be+=_bf;setTimeout(_ca,_sp12);};var _cb=function(_cc){return (_c7[_cc+"!"]!=undefined);};var _cd={};var _ce;var _cf=function(lw,_d0){_ce=lw;var _d1=[];for(var _d2 in _ce){_d1.push(_d2);}
var _d3=_sp51(_d1,function(_d4,_d5){if(_ce[_d4]<_ce[_d5]){return -1;}
if(_ce[_d4]>_ce[_d5]){return 1;}
return 0;});for(var i=0;i<alphabet.length;i++){_cd[alphabet[i]]=0;}
for(var i=0;i<_d3.length;i++){_cd[_d3[i]]=i+1;}
_sp48(_be,_be+_bf);_be+=_bf;setTimeout(_d0,_sp12);};var _d6={};var _d7=[];var _d8=function(i,_d9){for(;i<_c0.length;i++){var _da=_c0[i];if(_da.length>=_sp3&&_da.length<=_sp4){var _db=0;for(var j=0;j<_da.length;j++){_db+=_cd[_da[j]];}
_d6[_da]=_db+Math.random()/2;_d7.push(_da);}
if(i%_sp11==0){_sp49(i*100/(_c0.length-1));setTimeout(function(){_d8(i+1,_d9);},_sp12);return;}
}
_sp48(_be,_be+_bf);_be+=_bf;setTimeout(function(){_d7=_sp51(_d7,function(one,two){return _d6[two]-_d6[one];});setTimeout(_d9,_sp12);},_sp12);};var _dc=Number.MAX_VALUE;var _dd;var _de=0;var _df;var _e0=[];var _e1=function(i,_e2){if(i==0){_dd=new Array(_d7[0]);_df=_d7.length*_sp2.length;_sp48(_be,99);if(_sp2.length>alphabet.length){setTimeout(_e2,_sp12);return;}
var _e3={};var _e4=0;for(var _e5 in _ce){if(Math.floor(_ce[_e5])==1){_e3[_e5]=1;_e4++;}
}
if(_e4<_sp2.length){setTimeout(_e2,_sp12);return;}
for(var j=0;j<_sp2.length;j++){var _e6=_sp2[j];var _e7="";for(var _e5 in _e3){if(_e6.indexOf(_e5)!=-1){_e7+=_e5;}
}
if(_e7==""){_e0=[];setTimeout(_e2,_sp12);return;}
_e0.push(new RegExp("^[^"+_e7+"]*"+"["+_e7+"]"+"[^"+_e7+"]*$"));}
_df+=_d7.length;}
if(_e0.length>0&&_c1){for(;i<_d7.length;i++){var _e8=_d7[i];var _e9=_sp2.length;for(var j=0;j<_e0.length;j++){if(_e8.search(_e0[j])!=-1){_e9--;}
}
if(_e9<_dc){_dc=_e9;_dd=new Array(_e8);}else{if(_e9==_dc){_dd.push(_e8);}
}
_de++;if(_de%_sp11==0){var _ea=_de*100/_df;var _eb=(new Date().getTime()-_bb)*100/_b9;_sp49(Math.max(_ea,_eb));setTimeout(function(){_e1(i+1,_e2);},_sp12);return;}
}
}
setTimeout(_e2,_sp12);};var _ec=function(i,_ed){for(;i<_d7.length;i++){if(_e0.length>0&&!_c1){_dd=_sp2;_df-=_d7.length*_sp2.length;break;}
var _ee=_d7[i];var _ef={};for(var c=0;c<_ee.length;c++){var _f0=_ee[c];if(_ef[_f0]==undefined){_ef[_f0]=1;}else{_ef[_f0]++;}
}
var _f1={};var _f2=function(j,_f3){for(;j<_sp2.length;j++){var _f4=_sp2[j];var _f5=0;var _f6={};for(var _f7 in _ef){_f6[_f7]=_ef[_f7];}
for(var k=0;k<_f4.length;k++){var _f7=_f4[k];if(_f6[_f7]!=undefined&&_f6[_f7]>0){_f5++;_f6[_f7]--;}
}
if(_f1[_f5]==undefined){_f1[_f5]=1;}else{_f1[_f5]++;}
_de++;if(_de%_sp11==0){var _f8=_de*100/_df;var _f9=(new Date().getTime()-_bb)*100/_b9;_sp49(Math.max(_f8,_f9));setTimeout(function(){_f2(j+1,_f3);},_sp12);return;}
}
var _f9=(new Date().getTime()-_bb)*100/_b9;if(_f9-_bc>5){_bc=_f9;var _f8=_de*100/_df;_sp49(Math.max(_f8,_f9));setTimeout(_f3,_sp12);return;}
_f3();};_f2(0,function(){var _fa=0;var _fb=1;var _fc=0;for(var _fd in _f1){var _fe=_f1[_fd];_fa=Math.max(_fa,_fe);_fb*=_fe;_fc++;}
_fb=Math.pow(_fb,1/_fc);var _ff=_fa+_fb/(2*_sp2.length);if(!_cb(_ee)){_ff++;}
if(_sp8[_ee]!=undefined){_ff*=_sp2.length;}
if(_ff<_dc){_dc=_ff;_dd=new Array(_ee);}else{if(_ff==_dc){_dd.push(_ee);}
}
setTimeout(function(){if(new Date().getTime()-_bb<_b9){_ec(i+1,_ed);}else{_bd=1;_ec(_d7.length,_ed);}
},_sp12);});return;}
if(_dd.length>1){var _100=[];for(var i=0;i<_dd.length;i++){var word=_dd[i];if(_cb(word)){_100.push(word);}
}
if(_100.length>0){_dd=_100;}
}
var _101=_dd[Math.floor(Math.random()*_dd.length)];setTimeout(function(){_ed(_101);},_sp12);if(_c4==""){var _102=_de*100/_df;if(_102<1){_102=_102.toString().replace(/(\.0*[1-9]).*$/,"$1")+"%";}else{_102=_102.toString().replace(/(\.\d).*$/,"$1")+"%";}
var _103=(_d7.length*_sp2.length).toString();_103=_103.split("").reverse().join("");_103=_103.replace(/(\d\d\d)(?=\d)/g,"$1,");_103=_103.split("").reverse().join("");_c4=("(found by analyzing "+_102+" of "+_103+" possible scenarios");if(_bd){_c4+=" before reaching the "+(_b9/1000)+"-second time limit";}
_c4+=").";}
};setTimeout(function(){_c2(function(){_c5(function(){_c9(0,function(){_sp96(_c8,function(_104){_cf(_104,function(){_d8(0,function(){_e1(0,function(){_ec(0,function(_105){_sp47();_ba(_105,_c4);});});});});});});});});});};function _sp151(_106,_107,cont){_sp41(0,100);var _108=function(_109){if(wordListChanged){_sp48(0,50);_sp56(function(){_106=_sp2.join("\n");_sp27(function(){_sp48(50,100);setTimeout(_109,_sp12);});});}else{setTimeout(_109,_sp12);}
};var _10a=function(_10b){var _10c=[];for(var i=0;i<alphabet.length;i++){_sp49(i*100/(alphabet.length-1));if(_106.indexOf(alphabet[i])!=-1){_10c.push(alphabet[i]);}
}
var _10d;if(_10c.length==0){_10d="?";}else{_10d=_10c[Math.floor(Math.random()*_10c.length)];}
setTimeout(function(){_10b(_10d);},_sp12);};setTimeout(function(){_108(function(){_10a(function(_10e){_sp47();cont(_10e,"");});});},_sp12);};function _sp154(_10f,_110,cont){_sp41(0,100);var _111=function(_112){if(wordListChanged){_sp48(0,50);_sp56(function(){if(_10f==_sp6&&_sp2.length>2){_sp98=_sp7;}else{_sp98=_sp2;_10f=_sp2.join("\n");}
_sp27(function(){_sp48(50,100);setTimeout(_112,_sp12);});});}else{setTimeout(_112,_sp12);}
};var _113;var _114=function(_115){if(_10f==_sp13("word-list")){_113=_116;setTimeout(_115,_sp12);}else{var _116=_10f.replace(/\r/g,"").split("\n");_113=[];var i;var _117=function(i,_118){for(;i<_116.length;i++){var word=_116[i];if(word.length>=_sp3&&word.length<=_sp4){_113.push(word);}
if(i%_sp11==0){if(_116.length>1){_sp49(i*100/(_116.length-1));}
setTimeout(function(){_117(i+1,_118);},_sp12);return;}
}
setTimeout(_118,_sp12);};_117(0,_115);}
};var _119=function(){var _11a;if(_113.length==0){_11a="???";}else{_11a=_113[Math.floor(Math.random()*_113.length)];}
_sp47();setTimeout(function(){cont(_11a,"");},_sp12);};setTimeout(function(){_111(function(){_114(function(){_119();});});},_sp12);};function processGuess(){_sp16(true);var _11b=_sp13("guess-how").selectedIndex;var _11c=_sp13("guess-what").selectedIndex;var _11d=_sp13("guess-from").selectedIndex;var _11e=Number(_sp13("guess-time-limit").value)*1000;var _11f=_11b==0?"Determining the best":"Selecting a random";var _120=(_11c==0)?"word":"letter";var _121=_11d==0?_sp6:_sp13("word-list").value;if(_11d==0){_sp40(_11f+" "+_120+" to guess from the original list"+(_11c==0?" while honoring current word lengths&hellip;":"&hellip;"));}else{_sp40(_11f+" "+_120+" to guess from the current list of words&hellip;");}
var _122;switch(_11b*2+_11c){case 0:
_122=_sp110;break;case 1:
_122=_sp103;break;case 2:
_122=_sp154;break;case 3:
_122=_sp151;break;}
setTimeout(function(){_122(_121,_11e,function(_123,_124){_sp13("current-guess").innerHTML=_123.toUpperCase();_sp13("current-guess-statistics").innerHTML=_124;if(_11c==0){_sp8[_123]=1;}else{_sp9[_123]=1;}
_sp5.push(_sp2.length);_sp27(function(){});_sp50();_sp16(false);_sp13("current-guess-text").style.display="block";});},_sp12);};function _sp166(){var _125={};for(var key in _sp8){_125[key]=_sp8[key];}
var _126={};for(var key in _sp9){_126[key]=_sp9[key];}
_sp10.push({"word-list":_sp13("word-list").value,"prev-word-guesses":_125,"prev-letter-guesses":_126,"word-tally-history":_sp5.slice(0)});};function processUndo(){if(_sp10.length>0){_sp16(true);_sp40("Undoing the previous operation&hellip;");setTimeout(function(){var _127=_sp10.pop();_sp13("word-list").value=_127["word-list"];_sp8=_127["prev-word-guesses"];_sp9=_127["prev-letter-guesses"];_sp5=_127["word-tally-history"];_sp56(function(){_sp27(function(){_sp50();_sp16(false);});});},_sp12);}
};function resetList(){_sp16(true);_sp166();var _128=_sp13("word-list");_128.style.display="none";_sp13("toggle-list").innerHTML="Show words";setTimeout(function(){_128.value=_sp6;_sp8={};_sp9={};_sp2=_sp7;_sp3=_sp1;_sp4=_sp0;_sp5=[];_sp27(function(){wordListChanged=false;_sp16(false);});},_sp12);};function toggleList(){var _129=_sp13("toggle-list");var _12a=_sp13("word-list");if(_12a.style.display=="block"){_12a.style.display="none";_129.innerHTML="Show words";}else{_12a.style.display="block";_129.innerHTML="Hide words";}
};function setList(){_sp16(true);_sp166();_sp40("Replacing the original word list with the current list&hellip;");_sp56(function(){_sp27(function(){_sp6=_sp13("word-list").value;_sp7=_sp2;_sp1=_sp4;_sp0=_sp4;_sp50();_sp16(false);});});};function _sp170(cont){var _12b=_sp13("compressed-word-list").innerHTML;var _12c=_12b.match(/\d+[a-z]+/g);var _12d=function(_12e){var _12f=(location.hostname+location.pathname).replace(/[\/]$/,"");var _130=0;var _131=1009;for(var c=_12f.length-1;c>=0;c--){_130=(_130+_12f.charCodeAt(c))%_131;}
_12c=_12c.concat(_12c.slice(0,_130));_12c.splice(0,_130);if(_12c[_12c.length-1]=="3urgy"){setTimeout(_12e,_sp12);}else{_sp13("progress-box").style.display="none";_sp183();var _132=document.getElementsByTagName("h1");for(var e=_132.length-2;e>=0;e--){_132.item(e).style.display="none";}
}
};_sp2=[];var _133="";var _134=/^(\d+)([a-z]+)$/;var i=0;var _135=function(i,_136){for(;i<_12c.length;i++){var _137=_134.exec(_12c[i]);var _138=Number(_137[1]);var _139=_137[2];var word=_133.substr(0,_138)+_139;_sp2.push(word);_133=word;if(i%_sp11==0){_sp49(i*100/(_12c.length-1));setTimeout(function(){_135(i+1,_136);},_sp12);return;}
}
setTimeout(_136,_sp12);};_12d(function(){_135(0,function(){_sp13("word-list").value=_sp2.join("\n");setTimeout(cont,_sp12);});});};function _sp183(){for(var _13a in {"help":0,"help-word-length":0,"help-must-contain":0,"help-num-occurrences":0,"help-subset":0,"help-letter-set":0,"help-letter-pattern":0,"help-regular-expression":0,"help-guess-word":0,"examples":0}){_sp13(_13a).style.display="none";}
};function initializeWordFilter(){_sp16(true);if(self!=top){window.open(location.protocol+"//www.pakin.org/wordfilter.html","_top","");return;}
_sp40("Initializing.  Please wait.");_sp13("word-count").text="";_sp183();_sp41(0,100);setTimeout(function(){_sp48(0,25);_sp170(function(){_sp48(25,100);_sp56(function(){_sp27(function(){_sp6=_sp13("word-list").value;_sp7=_sp2;_sp36("must-contain-pos");_sp31("num-occurrences-letter");_sp13("toggle-list").style.display="inline-block";_sp13("reset-list").style.display="inline-block";_sp13("set-list").style.display="inline-block";_sp50();_sp16(false);_sp13("follow-instructions").style.display="inline";});});});},_sp12);};

