public Cube Create(Func <bool, int, char> CheckRules, HyperCube hyperCube, int w) { Cube newCube = new(); foreach (var plane in Planes) { int z = plane.Key; newCube.Planes.Add(z, plane.Value.Create(CheckRules, hyperCube, w, z)); } return(newCube); }
public Plane Create(Func <bool, int, char> CheckRules, HyperCube hyperCube, int w, int z) { List <string> newPlane = new List <string>(); for (int y = 0; y < Height; y++) { string newLine = ""; for (int x = 0; x < Width; x++) { newLine += CheckRules(IsOccupied(x, y), hyperCube.ActiveAround(w, z, x, y)); } newPlane.Add(newLine); } return(new Plane(newPlane)); }
public static void Execute(string filename) { List <string> input = File.ReadAllLines(filename).ToList(); Cube cube = new Cube(0, new Plane(input)); for (int count = 0; count < 6; count++) { cube.Expand(); cube.Generate(CheckRules); } Console.WriteLine($"Part One: {cube.CountOccupied()}"); HyperCube hyperCube = new HyperCube(0, new Cube(0, new Plane(input))); for (int count = 0; count < 6; count++) { hyperCube.Expand(); hyperCube.Generate(CheckRules); } Console.WriteLine($"Part Two: {hyperCube.CountOccupied()}"); }