示例#1
0
        public void CanMoveInOneStepTestAllFalse()
        {
            StreetProblems target = new StreetProblems();

            Assert.IsFalse(target.CanMoveInOneSetp("ABC", "ABECD"));
            Assert.IsFalse(target.CanMoveInOneSetp("ABC", "A"));
            Assert.IsFalse(target.CanMoveInOneSetp("ABCD", "ABCD"));
        }
示例#2
0
        public void MainTestCase()
        {
            StreetProblems target = new StreetProblems();

            target.Dictionary = dictionary;

            Assert.AreEqual(4, target.Solve("BIG", "CAT"));
            Assert.AreEqual(3, target.Solve("BAT", "CAR"));
        }
示例#3
0
        public void CanMoveInOneStepTestAllTrue()
        {
            StreetProblems target = new StreetProblems();

            Assert.IsTrue(target.CanMoveInOneSetp("ABC", "ABF"));
            Assert.IsTrue(target.CanMoveInOneSetp("AB", "ABF"));
            Assert.IsTrue(target.CanMoveInOneSetp("ABC", "AB"));
            Assert.IsTrue(target.CanMoveInOneSetp("BIG", "BIT"));
            Assert.IsTrue(target.CanMoveInOneSetp("BAT", "BIT"));
            Assert.IsTrue(target.CanMoveInOneSetp("BAT", "BUT"));
            Assert.IsTrue(target.CanMoveInOneSetp("BAT", "CAT"));
        }
示例#4
0
        static void Main()
        {
            string[]     dictionary;
            SourceDest[] sourceDestPair;

            try
            {
                ParseInput(out dictionary, out sourceDestPair);

                foreach (var item in sourceDestPair)
                {
                    if (dictionary.Where(s => s == item.Source).Count() != 1)
                    {
                        throw new ArgumentException("Missing " + item.Source);
                    }

                    if (dictionary.Where(s => s == item.Destination).Count() != 1)
                    {
                        throw new ArgumentException("Missing " + item.Destination);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Invalid input");
                Console.WriteLine(ex.ToString());
                return;
            }

            StreetProblems target = new StreetProblems();

            target.Dictionary = dictionary;

            foreach (var pairs in sourceDestPair)
            {
                Console.WriteLine(target.Solve(pairs.Source, pairs.Destination));
            }
        }