using System; using System.Collections.Generic; using System.IO; using System.Linq; using static D24._1.Program; namespace D24._2 { class Program { static void Main(string[] args) { var file = File.ReadAllText(args[0]).Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); var poi = new Dictionary(); var map = ParseMap(file, poi); var perm = GetPermutations(poi.Keys.OrderBy(p => p).Skip(1), poi.Count - 1); int minStep = int.MaxValue; foreach (var p in perm) { var current = 0; int step = 0; foreach (var destination in p.Append(0)) { step += Solve(map, poi[current], poi[destination]); current = destination; } if (step < minStep) minStep = step; } Console.WriteLine($"The answer is : {minStep}"); } } }