private static bool EvalAddPopularPasswordPattern(List <QePatternInstance>[] vPatterns, char[] vPassword, int i, char[] vSub, double dblCostPerMod) { ulong uDictSize; if (!PopularPasswords.IsPopularPassword(vSub, out uDictSize)) { return(false); } int n = vSub.Length; int d = HammingDistribution(vSub, 0, vPassword, i, n); double dblCost = Log2((double)uDictSize); // dblCost += log2(n binom d) int k = Math.Min(d, n - d); for (int j = n; j > (n - k); --j) { dblCost += Log2(j); } for (int j = k; j >= 2; --j) { dblCost -= Log2(j); } dblCost += dblCostPerMod * (double)d; vPatterns[i].Add(new QePatternInstance(i, n, PatternId.Dictionary, dblCost)); return(true); }