예제 #1
0
        public Task <IBenchmarkedSolution> GetBenchmarkedSolutionAsync(IProblem problem)
        {
            var existingSolutions = solutions.Where(x => x.ProblemNumber == problem.Number);

            if (!HasSolution(problem))
            {
                throw new InvalidOperationException("problem not solved");
            }

            return(Task.FromResult((IBenchmarkedSolution)BenchmarkedSolution.Create(existingSolutions.First())));
        }
예제 #2
0
        public static BenchmarkedSolution Create(ISolution solution)
        {
            var stopwatch = Stopwatch.StartNew();

            var bs = new BenchmarkedSolution()
            {
                answer = solution.GetAnswer(), ElapsedMiliseconds = stopwatch.ElapsedMilliseconds, ProblemNumber = solution.ProblemNumber
            };

            return(bs);
        }