Exemple #1
0
    public bool ProveA()
    {
        var eris  = new Eris();
        var lines = File.ReadAllLines(Example, Encoding.UTF8);

        for (var y = 0; y < 5; y++)
        {
            for (var x = 0; x < 5; x++)
            {
                eris.SetBug(x, y, lines[y][x] == '#');
            }
        }
        return(SimpleSolution(eris, false) == 2129920);
    }
Exemple #2
0
    private string SolveA()
    {
        var eris  = new Eris();
        var lines = File.ReadAllLines(Input, Encoding.UTF8);

        for (var y = 0; y < 5; y++)
        {
            for (var x = 0; x < 5; x++)
            {
                eris.SetBug(x, y, lines[y][x] == '#');
            }
        }
        return(SimpleSolution(eris, false).ToString());
    }
Exemple #3
0
        public Eris Iterate()
        {
            var next = new Eris();

            for (var y = 0; y < 5; y++)
            {
                for (var x = 0; x < 5; x++)
                {
                    int  neighbors = NeighboringBugs(x, y);
                    bool hasBug    = GetBug(x, y);
                    bool isBug     = hasBug ? (neighbors == 1) : (neighbors == 1 || neighbors == 2);
                    next.SetBug(x, y, isBug);
                }
            }
            return(next);
        }