Esempio n. 1
0
 public void DrawWire(Wire wire, WirePath path)
 {
     foreach (var point in path.Walk(CentralPort))
     {
         if (!_cells.TryGetValue(point, out var cell))
         {
             cell = new GridCell();
             _cells.Add(point, cell);
         }
         cell.CrossedBy(wire);
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var grid = new Grid();
            var wire = new Wire(1);

            foreach (var line in File.ReadAllLines(args[0]))
            {
                var path = WirePath.FromPathString(line);
                grid.DrawWire(wire, path);
                wire = wire.Next();
            }
            Console.WriteLine(grid.WhatIsTheShortestDistanceToCentralPortFromTheClosestIntersection());
        }