/// <summary> /// Determines whether another word can be constructed that includes the impostor letter. /// </summary> /// <param name="impostor">The impostor letter.</param> /// <param name="solution">The current solution.</param> /// <returns>True if the impostor character cannot create a valid word.</returns> internal static bool IsValidImpostor(this char impostor, string solution) { if (solution.Select(c => ValidAlphabet.IndexOf(c)).Any(i => Math.Abs(i - ValidAlphabet.IndexOf(impostor)) <= 1)) { return(false); } foreach (char potentialImpostor in solution.Distinct()) { if (ValidDistinctWords.Contains(solution.Select(c => c != potentialImpostor).Join(""))) { return(false); } } return(true); }
/// <summary> /// Logs all information about the variables. /// </summary> private static void Log() { Debug.LogWarningFormat("Log method initalized. Dumping all variables... Make sure that you only receive at most 430 warnings! (Press the warning icon in the top-right part of the console to hide this logging!)"); for (int i = 0; i < ValidWords.Length; i++) { Debug.LogWarningFormat("{0}: {1}.", i, ValidWords[i].Join(", ")); } Debug.LogWarningFormat("Valid alphabet: {0}.", ValidAlphabet.Join(", ")); Debug.LogWarningFormat("Valid character sequence: {0}.", ValidChars.Join(", ")); Debug.LogWarningFormat("The shortest words are: {0}.", GetShortest().Join(", ")); Debug.LogWarningFormat("The longest words are: {0}.", GetLongest().Join(", ")); Debug.LogWarningFormat("The smallest length of a given index is: {0}", GetShortestLength()); Debug.LogWarningFormat("The longest length of a given index is: {0}", GetLongestLength()); Debug.LogWarningFormat("The indexes that don't meet the required {0} length are: {1}", MinAcceptableWordSet, ValidWords.Where(a => a.Length < MinAcceptableWordSet).Select(a => Array.IndexOf(ValidWords, a)).Join(", ")); Debug.LogWarningFormat("The amount of distinct to total words are: {0}/{1}.", GetCount(distinct: true), GetCount(distinct: false)); Debug.LogWarningFormat("The words that are completely unique are: {0}.", ValidDistinctWords.GroupBy(x => x).Where(g => g.Count() == 1).Select(y => y.Key).Join(", ")); }