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); }
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()); }
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); }