예제 #1
0
 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");
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
        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();
        }
예제 #4
0
 public void ValidateThreeVowels()
 {
     Santa santa = new Santa();
     bool actual = santa.IsNiceString("aaa");
     Assert.AreEqual(true, actual);
 }
예제 #5
0
 public void ValidateNiceString()
 {
     Santa santa = new Santa();
     bool actual = santa.IsNiceString("ugknbfddgicrmopn");
     Assert.AreEqual(true, actual);
 }
예제 #6
0
 public void ValidateNaughtyOneVowel()
 {
     Santa santa = new Santa();
     bool actual = santa.IsNiceString("dvszwmarrgswjxmb");
     Assert.AreEqual(false, actual);
 }
예제 #7
0
 public void ValidateNaughtyNoDouble()
 {
     Santa santa = new Santa();
     bool actual = santa.IsNiceString("jchzalrnumimnmhp");
     Assert.AreEqual(false, actual);
 }
예제 #8
0
 public void ValidateNaughtyBadString()
 {
     Santa santa = new Santa();
     bool actual = santa.IsNiceString("haegwjzuvuyypxyu");
     Assert.AreEqual(false, actual);
 }
예제 #9
0
 public void TestTwoRepeatingCharacterPattern()
 {
     Santa santa = new Santa();
     Assert.AreEqual(true, santa.MatchRepeatingCharacter("abcdefeghi"));
     Assert.AreEqual(true, santa.MatchRepeatingCharacter("aaa"));
 }