Esempio n. 1
0
        public void Day03Part2_TestSolution()
        {
            string[] vectors = DayDataUtilities.ReadLinesFromFile("day03.txt");

            Assert.Equal(2, vectors.Length);
            List <string> cmds0 = new List <string>(vectors[0].Split(','));
            List <string> cmds1 = new List <string>(vectors[1].Split(','));

            Assert.NotNull(cmds0);
            Assert.NotNull(cmds1);

            PathCmdsToPoints pathMaker = new PathCmdsToPoints();
            List <Point>     path0     = pathMaker.ParsePath(cmds0);
            List <Point>     path1     = pathMaker.ParsePath(cmds1);

            int actualSteps = pathMaker.FindLeastStepsIntersection(path0, path1);

            Assert.Equal(37390, actualSteps);
        }
Esempio n. 2
0
        public void Day03Part2_StepsExamples(string data0, string data1, int expectedSteps)
        {
            List <string> cmds0 = new List <string>(data0.Split(','));
            List <string> cmds1 = new List <string>(data1.Split(','));

            Assert.NotNull(cmds0);
            Assert.NotNull(cmds1);

            PathCmdsToPoints pathMaker = new PathCmdsToPoints();
            List <Point>     path0     = pathMaker.ParsePath(cmds0);
            List <Point>     path1     = pathMaker.ParsePath(cmds1);

            Assert.NotNull(path0);
            Assert.Equal(cmds0.Count + 1, path0.Count);
            Assert.NotNull(path1);
            Assert.Equal(cmds1.Count + 1, path1.Count);

            int actualSteps = pathMaker.FindLeastStepsIntersection(path0, path1);

            Assert.Equal(expectedSteps, actualSteps);
        }
Esempio n. 3
0
        public void Day03Part1_Examples(string data0, string data1, int expectedDist)
        {
            List <string> cmds0 = new List <string>(data0.Split(','));
            List <string> cmds1 = new List <string>(data1.Split(','));

            Assert.NotNull(cmds0);
            Assert.NotNull(cmds1);

            PathCmdsToPoints pathMaker = new PathCmdsToPoints();
            List <Point>     path0     = pathMaker.ParsePath(cmds0);
            List <Point>     path1     = pathMaker.ParsePath(cmds1);

            Assert.NotNull(path0);
            Assert.Equal(cmds0.Count + 1, path0.Count);
            Assert.NotNull(path1);
            Assert.Equal(cmds1.Count + 1, path1.Count);

            int actualDist = pathMaker.FindAllInterSections(path0, path1);

            Assert.Equal(expectedDist, actualDist);
        }