Exemple #1
0
        public void FindAllRoutes_GetTwoPaths()
        {
            var tree = _parser.Build(new string[] { "1", "2 4" });

            var routes = _solver.FindAllRoutes(tree);

            // Expecting 2 valid routes: 1->2 and 1->4
            routes.Should().HaveCount(2);
        }
Exemple #2
0
 private static void FindAllRoutes()
 {
     string[] lines = SelectFileAndReadLines();
     if (lines?.Length > 0)
     {
         var matrix = _parser.Build(lines);
         var routes = _solver.FindAllRoutes(matrix);
         if (routes?.Length > 0)
         {
             Output.WriteLine(ConsoleColor.Green, "Got {0} available routes", routes.Length);
             foreach (var r in routes)
             {
                 Console.WriteLine("{0} ({1})", String.Join(" -> ", r.Path), r.Sum);
             }
         }
         else
         {
             Output.WriteLine(ConsoleColor.Red, "No routes found.");
         }
     }
 }