Пример #1
0
        public void TestCase02()
        {
            /*
             * 7
             * 1
             * G
             * 2
             * GR
             * 4
             * _GR_
             * 5
             * _R_G_
             * 5
             * R_R_R
             * 8
             * RRGGBBXX
             * 8
             * RRGGBBXY
             */

            Assert.AreEqual("NO", HappyLadybugs.IsHappy("G"));
            Assert.AreEqual("NO", HappyLadybugs.IsHappy("GR"));
            Assert.AreEqual("NO", HappyLadybugs.IsHappy("_GR_"));
            Assert.AreEqual("NO", HappyLadybugs.IsHappy("_R_G_"));
            Assert.AreEqual("YES", HappyLadybugs.IsHappy("R_R_R"));
            Assert.AreEqual("YES", HappyLadybugs.IsHappy("RRGGBBXX"));
            Assert.AreEqual("NO", HappyLadybugs.IsHappy("RRGGBBXY"));
        }
Пример #2
0
        public void TestHappyLadybugs()
        {
            //https://www.hackerrank.com/challenges/happy-ladybugs/problem

            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("RBY_YBR"));
            Assert.AreEqual("NO", HappyLadybugs.happyLadybugs("X_Y__X"));
            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("__"));
            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("B_RRBR"));

            Assert.AreEqual("NO", HappyLadybugs.happyLadybugs("AABBC"));
            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("AABBC_C"));
            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("_"));
            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("DD__FQ_QQF"));
            Assert.AreEqual("NO", HappyLadybugs.happyLadybugs("AABCBC"));

            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("_"));
            Assert.AreEqual("NO", HappyLadybugs.happyLadybugs("RBRB"));
            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("RRRR"));
            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("BBB"));
            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("BBB_"));

            Assert.AreEqual("NO", HappyLadybugs.happyLadybugs("G"));
            Assert.AreEqual("NO", HappyLadybugs.happyLadybugs("GR"));
            Assert.AreEqual("NO", HappyLadybugs.happyLadybugs("_GR_"));
            Assert.AreEqual("NO", HappyLadybugs.happyLadybugs("_R_G_"));
            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("R_R_R"));
            Assert.AreEqual("YES", HappyLadybugs.happyLadybugs("RRGGBBXX"));
            Assert.AreEqual("NO", HappyLadybugs.happyLadybugs("RRGGBBXY"));
        }
Пример #3
0
        private void CompareInputToExpectedOutput(string input, string output)
        {
            input  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Test Input/HappyLadyBugs", input);
            output = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Test Input/HappyLadyBugs", output);

            int          line_count = 1; // useful for debugs..
            string       line;
            StreamReader sr_in  = new StreamReader(input);
            StreamReader sr_out = new StreamReader(output);

            int cases = Convert.ToInt32(sr_in.ReadLine());

            for (int i = 0; i < cases; i++)
            {
                sr_in.ReadLine(); //read in and throw away the string length.
                Assert.AreEqual(sr_out.ReadLine(), HappyLadybugs.IsHappy(sr_in.ReadLine()));
            }
        }
Пример #4
0
        public void TestCase00()
        {
            /*
             * 4
             * 7
             * RBY_YBR
             * 6
             * X_Y__X
             * 2
             * __
             * 6
             * B_RRBR
             */

            Assert.AreEqual("YES", HappyLadybugs.IsHappy("RBY_YBR"));
            Assert.AreEqual("NO", HappyLadybugs.IsHappy("X_Y__X"));
            Assert.AreEqual("YES", HappyLadybugs.IsHappy("__"));
            Assert.AreEqual("YES", HappyLadybugs.IsHappy("B_RRBR"));
        }
Пример #5
0
        public void TestCase01()
        {
            /*
             * 5
             * 1
             * _
             * 4
             * RBRB
             * 4
             * RRRR
             * 3
             * BBB
             * 4
             * BBB_
             */

            Assert.AreEqual("YES", HappyLadybugs.IsHappy("_"));
            Assert.AreEqual("NO", HappyLadybugs.IsHappy("RBRB"));
            Assert.AreEqual("YES", HappyLadybugs.IsHappy("RRRR"));
            Assert.AreEqual("YES", HappyLadybugs.IsHappy("BBB"));
            Assert.AreEqual("YES", HappyLadybugs.IsHappy("BBB_"));
        }
Пример #6
0
 public void NoBlankTest()
 {
     Assert.AreEqual("YES", HappyLadybugs.IsHappy("RRBBYY"));
     Assert.AreEqual("NO", HappyLadybugs.IsHappy("RYRY"));
 }
Пример #7
0
 public void TestCase06()
 {
     Assert.AreEqual("NO", HappyLadybugs.IsHappy("IJNPTY_HGHDR_QDIOJSIQXCUBXNKI_DJ_JOHXBJQ_HJD_IGOITUKXDIPSUHJOU_KTSSQDGHBUQIIG"));
     Assert.AreEqual("NO", HappyLadybugs.IsHappy("B_XZVJK_UTM_XUOJML_RHYDJSR_KLZBOMXMJJ_YJBZOZ_BXKZOLBUBXRYROOHX_O_UBJHVBKVJJURM_ZXKMTVJXYJ_JRK"));
     Assert.AreEqual("NO", HappyLadybugs.IsHappy("BGRBSL_DRDKHYJQQCVRS_EMSDEBJB_KRQQGYMDRHQYSSGDHRQESRRD_SMCRDEJJDSDVQBS"));
 }