public void TestSimulate()
        {
            MotionSimulator ms = new MotionSimulator();

            Moon A = new Moon(-1, 0, 2);
            Moon B = new Moon(2, -10, -7);
            Moon C = new Moon(4, -8, 8);
            Moon D = new Moon(3, 5, -1);

            List <Moon> moons = new List <Moon>();

            moons.Add(A);
            moons.Add(B);
            moons.Add(C);
            moons.Add(D);

            ms.Simulate(moons, 10);

            Assert.That(A.PosX, Is.EqualTo(2));
            Assert.That(A.PosY, Is.EqualTo(1));
            Assert.That(A.PosZ, Is.EqualTo(-3));
            Assert.That(A.VelX, Is.EqualTo(-3));
            Assert.That(A.VelY, Is.EqualTo(-2));
            Assert.That(A.VelZ, Is.EqualTo(1));
        }
Ejemplo n.º 2
0
        public string SolvePartOne(string[] input, int steps)
        {
            MotionSimulator ms = new MotionSimulator();

            List <Moon> moons = ParseInput(input);

            ms.Simulate(moons, steps);

            return(ms.SystemEnergy(moons).ToString());
        }