public override void PartTwo() { var dirs = Pos.Origin.Around().ToArray(); var game = new GameOfLife <Pos, int>(Empty, Taken); game.WithNeighborFunction(pos => dirs.ToTrace(pos, game, (_, i) => i > Floor)) .WithLivingDeadRules(i => i >= 5, i => i == 0); foreach (var(pos, c) in Input.As2D()) { game[pos] = Map(c); } game.StepUntil(i => i == 0); WriteLn(game.CountValues(Taken)); }
public static int CountState <TLoc, TState>(this GameOfLife <TLoc, TState> game, TState state) { return(game.CountValues(state)); }
public static int CountActive <T>(this GameOfLife <T, bool> game) { return(game.CountValues(true)); }
public override void PartOne() { Step(2); WriteLn(Game.CountValues(true)); }