static void Main(string[] args) { var b = new Moon() { Position = new P3(17, -7, -11) }; var c = new Moon() { Position = new P3(1, 4, -1) }; var a = new Moon() { Position = new P3(6, -2, -6) }; var d = new Moon() { Position = new P3(19, 11, 9) }; var system = new MoonSystem(new[] { a, b, c, d }); system.Turn(1000); Console.WriteLine($"Part 1:{system.Energy}"); system.Reset(); var sw = Stopwatch.StartNew(); var cycle = system.CalculateCycle(); sw.Stop(); Console.WriteLine($"Part 2:{cycle} in {sw.ElapsedMilliseconds}ms"); }
public void Part2_Example1() { var a = new Moon() { Position = new P3(-1, 0, 2) }; var b = new Moon() { Position = new P3(2, -10, -7) }; var c = new Moon() { Position = new P3(4, -8, 8) }; var d = new Moon() { Position = new P3(3, 5, -1) }; var system = new MoonSystem(a, b, c, d); var cycle = system.CalculateCycle(); Assert.Equal(2772L, cycle); }
public void Part2_Example2() { var b = new Moon() { Position = new P3(-8, -10, 0) }; var c = new Moon() { Position = new P3(5, 5, 10) }; var a = new Moon() { Position = new P3(2, -7, 3) }; var d = new Moon() { Position = new P3(9, -8, -3) }; var system = new MoonSystem(a, b, c, d); var cycle = system.CalculateCycle(); Assert.Equal(4686774924L, cycle); }