private static void RunTest1() { var input = File.ReadAllLines(InputFile); var wire1 = new Wire(input[0].Split(',').Select(x => new Instruction(x)).ToList()); var wire2 = new Wire(input[1].Split(',').Select(x => new Instruction(x)).ToList()); var intersectionPoints = WireHelper.FindIntersectionsOfWires(wire1, wire2); var centralPortLocation = new Coordinate(0, 0); var distances = new List <int>(); foreach (var intersectionPoint in intersectionPoints) { distances.Add(intersectionPoint.GetManhattanDistanceTo(centralPortLocation)); Console.WriteLine($"Point: X: {intersectionPoint.X} Y: {intersectionPoint.Y} Distance: {intersectionPoint.GetManhattanDistanceTo(centralPortLocation)}"); } Console.WriteLine($"Distance to closest intersection: {distances.Min()}"); }
private static void RunTest2() { var input = File.ReadAllLines(InputFile); var wire1 = new Wire(input[0].Split(',').Select(x => new Instruction(x)).ToList()); var wire2 = new Wire(input[1].Split(',').Select(x => new Instruction(x)).ToList()); var intersectionPoints = WireHelper.FindIntersectionsOfWires(wire1, wire2); var distances = new List <int>(); foreach (var intersectionPoint in intersectionPoints) { var wire1Steps = wire1.StepsToCoordinate(intersectionPoint); var wire2Steps = wire2.StepsToCoordinate(intersectionPoint); distances.Add(wire1Steps + wire2Steps); Console.WriteLine($"Point: X: {intersectionPoint.X} Y: {intersectionPoint.Y} Wire1 Steps: {wire1Steps} Wire2Steps: {wire2Steps} Total Steps: {wire1Steps + wire2Steps}"); } Console.WriteLine($"Distance to closest intersection: {distances.Min()}"); }