public void TestTwoMatchingCharacters() { List<string> inputs = new List<string> {"xyxy", "aabcdefgaa"}; Santa santa = new Santa(); foreach (string input in inputs) { Assert.AreEqual(true, santa.MatchTwoLetters(input), input); } Assert.AreNotEqual(true, santa.MatchTwoLetters("aaa"), "aaa"); }
public void TestIsNiceString2() { Santa santa = new Santa(); List<string> equalList = new List<string> {"qjhvhtzxzqqjkmpb", "xxyxx"}; List<string> unequalList = new List<string> {"uurcxstgmygtbstg", "ieodomkazucvgmuy"}; foreach (string s in equalList) { Assert.AreEqual(true, santa.IsNiceString2(s), s); } foreach (string s in unequalList) { Assert.AreNotEqual(true, santa.IsNiceString2(s), s); } }
private static void Main(string[] args) { // Part 1 Santa santa = new Santa(); List<string> list = File.ReadAllLines("input.txt").ToList(); int niceStrings = list.Count(x => santa.IsNiceString(x)); Console.WriteLine( $"Part One: {list.Count} strings processed. {list.Count - niceStrings} strings marked as naughty. {niceStrings} strings are nice"); // Part 2 niceStrings = list.Count(x => santa.IsNiceString2(x)); Console.WriteLine( $"Part Two: {list.Count} strings processed. {list.Count - niceStrings} strings marked as naughty. {niceStrings} strings are nice"); Console.Write("Press any key..."); Console.ReadKey(); }
public void ValidateThreeVowels() { Santa santa = new Santa(); bool actual = santa.IsNiceString("aaa"); Assert.AreEqual(true, actual); }
public void ValidateNiceString() { Santa santa = new Santa(); bool actual = santa.IsNiceString("ugknbfddgicrmopn"); Assert.AreEqual(true, actual); }
public void ValidateNaughtyOneVowel() { Santa santa = new Santa(); bool actual = santa.IsNiceString("dvszwmarrgswjxmb"); Assert.AreEqual(false, actual); }
public void ValidateNaughtyNoDouble() { Santa santa = new Santa(); bool actual = santa.IsNiceString("jchzalrnumimnmhp"); Assert.AreEqual(false, actual); }
public void ValidateNaughtyBadString() { Santa santa = new Santa(); bool actual = santa.IsNiceString("haegwjzuvuyypxyu"); Assert.AreEqual(false, actual); }
public void TestTwoRepeatingCharacterPattern() { Santa santa = new Santa(); Assert.AreEqual(true, santa.MatchRepeatingCharacter("abcdefeghi")); Assert.AreEqual(true, santa.MatchRepeatingCharacter("aaa")); }