public void Run() { Console.OutputEncoding = Encoding.UTF8; var instructions = File.ReadAllText("Day19.txt") .Trim() .Split(",", StringSplitOptions.RemoveEmptyEntries) .Select(x => long.Parse(x)) .ToList(); int total = 0; for (int y = 0; y < 50; y++) { for (int x = 0; x < 50; x++) { var drone = new TractorDrone(x, y); var computer = new Computer(new Memory(instructions), drone); computer.Run(debug: false); Write(drone.IsPulled ? '#' : '.'); if (drone.IsPulled) { total++; } } WriteLine(); } WriteLine(total); }
private bool IsPulled(int x, int y) { if (!_map.TryGetValue((x, y), out var isPulled)) { var drone = new TractorDrone(x, y); new Computer(new Memory(_instructions), drone).Run(); isPulled = drone.IsPulled; _map[(x, y)] = isPulled;