using System; using System.Collections.Generic; using System.IO; using System.Linq; namespace D6._2 { class Program { static void Main(string[] args) { if (args.Length < 1) return; if (File.Exists(args[0]) == false) return; var coordinates = new List<(uint x, uint y)>(); var file = File.OpenText(args[0]); do { var line = file.ReadLine(); if (line == null) break; var cl = line.Split(", "); coordinates.Add((uint.Parse(cl[0]), uint.Parse(cl[1]))); } while (true); int area = 0; for (uint x = 0; x < 500; x++) { for (uint y = 0; y < 500; y++) { var total = GetTotalDistance(coordinates, x, y); if (total < 10000) area++; } } Console.WriteLine($"Answer : {area}"); } private static int GetTotalDistance(List<(uint x, uint y)> coordinates, uint x, uint y) { int total = 0; for (int i = 0; i < coordinates.Count; i++) { var coord = coordinates[i]; var manhattan = Math.Abs((int)x - (int)coord.x) + Math.Abs((int)y - (int)coord.y); total += manhattan; } return total; } } }