public void Test5() { string input = @"<x=-1, y=0, z=2> <x=2, y=-10, z=-7> <x=4, y=-8, z=8> <x=3, y=5, z=-1>"; List <string> moonStringList = input.Split("\r\n").ToList(); var jm = new JupiterMoons(moonStringList); var jm2 = (jm.Clone() as JupiterMoons); bool m = jm.Equals(jm2); Assert.AreEqual(jm, jm2); }
public void Test10() { string input = @"<x=-1, y=0, z=2> <x=2, y=-10, z=-7> <x=4, y=-8, z=8> <x=3, y=5, z=-1>"; List <string> moonStringList = input.Split("\r\n").ToList(); var jm = new JupiterMoons(moonStringList); var states = new HashSet <JupiterMoons>(); long steps = 0; bool repeatFound = false; JupiterMoons jm2 = null; while (!repeatFound) { jm.Tick(); if (states.TryGetValue(jm, out jm2)) { repeatFound = true; } else { states.Add((jm.Clone() as JupiterMoons)); steps++; } } Assert.AreEqual(jm, jm2); Assert.AreEqual(2772, steps); }