static void Main(string[] args) { var input = @"#.#.. .#.#. #...# .#..# ##.#."; var lifeGame = new LifeGame(input); var dico = new Dictionary <int, int>(); while (true) { lifeGame.Iterate(); var rating = lifeGame.BioDiversityRating; if (dico.TryGetValue(rating, out var counter)) { Console.WriteLine($"Result = {rating}"); break; } else { dico[rating] = 1; } } var lifeGame1 = new LifeGame(input); for (int i = 0; i < 200; i++) { lifeGame1.Iterate2(); } lifeGame1.Dump(); Console.WriteLine($"Bug Count={lifeGame1.BugCount}"); }
public void TestIterate() { var input = @"....# #..#. #.?## ..#.. #...."; var lifeGame = new LifeGame(input); for (int i = 0; i < 10; i++) { lifeGame.Iterate2(); } Assert.Equal(99, lifeGame.BugCount); }