Exemple #1
0
        static void QuestionTen(RouteGraph routeGraph)
        {
            Func <ExtendedRoute, TraverseType> predicate = (ExtendedRoute er) =>
            {
                if (er.Distance < 30)
                {
                    if (er.EndsWith("C"))
                    {
                        return(TraverseType.ReturnAndContinue);
                    }

                    return(TraverseType.Continue);
                }

                return(TraverseType.Stop);
            };

            Console.WriteLine(routeGraph.Traverse("C", predicate).Count);
        }
Exemple #2
0
        static void QuestionSeven(RouteGraph routeGraph)
        {
            Func <ExtendedRoute, TraverseType> predicate = (ExtendedRoute er) =>
            {
                if (er.Stops < 4)
                {
                    return(TraverseType.Continue);
                }

                if (er.Stops == 4 && er.EndsWith("C"))
                {
                    return(TraverseType.Return);
                }

                return(TraverseType.Stop);
            };

            Console.WriteLine(routeGraph.Traverse("A", predicate).Count);
        }