示例#1
0
文件: Day12.cs 项目: stefc/AoC
        public void LookForCycle(long expected, int sample)
        {
            var state = GetSample(sample)
                        .Select(moon => (pos: moon, vel: Point3D.Zero));

            var xCyle = state.FindCycle(p => p.X);
            var yCyle = state.FindCycle(p => p.Y);
            var zCyle = state.FindCycle(p => p.Z);


            var actual = NBodyProblem.lcm(
                NBodyProblem.lcm(xCyle, yCyle),
                zCyle);

            Assert.Equal(expected, actual);
        }
示例#2
0
文件: Day12.cs 项目: stefc/AoC
        public void PuzzleTwo()
        {
            var input = File.ReadLines("tests/y2019/Day12.Input.txt")
                        .GetMoonPositions()
                        .Select(moon => (pos: moon, vel: Point3D.Zero));

            var xCyle = input.FindCycle(p => p.X);
            var yCyle = input.FindCycle(p => p.Y);
            var zCyle = input.FindCycle(p => p.Z);


            var actual = NBodyProblem.lcm(
                NBodyProblem.lcm(xCyle, yCyle),
                zCyle);

            Assert.Equal(496734501382552, actual);
        }