示例#1
0
 public Cube3D(CubeSpace3D space, int x, int y, int z, bool state = false)
 {
     _space = space;
     X      = x;
     Y      = y;
     Z      = z;
     Active = state;
 }
示例#2
0
    public override string SolvePart1()
    {
        CubeSpace3D cubeSpace3D = GetCubeSpace3D();

        for (int i = 0; i < 6; i++)
        {
            cubeSpace3D.SimulateCycle();
        }
        int result = cubeSpace3D.ActiveCount;

        return(result.ToString());
    }
示例#3
0
    private CubeSpace3D GetCubeSpace3D()
    {
        string[] lines = InputLines.ToArray();
        if (!lines.All(line => line.Length == lines.Length))
        {
            throw new FormatException();
        }
        CubeSpace3D cube = new CubeSpace3D(lines.Length + 6 * 2);
        int         z    = cube.zLength / 2;

        for (int x = 0; x < lines.Length; x++)
        {
            for (int y = 0; y < lines[x].Length; y++)
            {
                if (lines[x][y] != '#')
                {
                    continue;
                }
                cube[x + 6, y + 6, z].Active = true;
            }
        }
        return(cube);
    }