public void TestApplyGravity() { var moons = Day12.ApplyGravity(new Moon[] { Moon.Parse("<x=-1, y= 0, z= 2>"), Moon.Parse("<x= 2, y=-10, z=-7>"), Moon.Parse("<x= 4, y= -8, z= 8>"), Moon.Parse("<x= 3, y= 5, z=-1>"), }); Assert.Equal(3, moons[0].Velocity.X); Assert.Equal(-1, moons[0].Velocity.Y); Assert.Equal(-1, moons[0].Velocity.Z); Assert.Equal(1, moons[1].Velocity.X); Assert.Equal(3, moons[1].Velocity.Y); Assert.Equal(3, moons[1].Velocity.Z); Assert.Equal(-3, moons[2].Velocity.X); Assert.Equal(1, moons[2].Velocity.Y); Assert.Equal(-3, moons[2].Velocity.Z); Assert.Equal(-1, moons[3].Velocity.X); Assert.Equal(-3, moons[3].Velocity.Y); Assert.Equal(1, moons[3].Velocity.Z); }
public void ApplyGravity() { var solver = new Day12(); var moons = solver.Parse(Input); moons = solver.ApplyGravity(moons); moons[0].ToString().ShouldBe("pos=<x= 2, y=-1, z= 1>, vel=<x= 3, y=-1, z=-1>"); }